kevinle92618 wrote: > > I don't have answers to your questions. I'm interested in knowing if > ActiveMQ has the "resume" transfer capability for large file. Please > reply if you have the answer. Thanks. >
It has been a while since I worked on this but I did get the "resume" working. As I recall, I kept track of the number of bytes transferred and if there was a failure I just had to resume and read past that many bytes and restart transfer. Here is a snippet from some sample code I created for testing. private static void startTransfer() throws Exception { RandomAccessFile outFile = null; InputStream in = null; byte[] buf = new byte[bufSize]; int len = 0; URLConnection conn = null; // len == -1 when end of InputStream is read while (len != -1) { try { conn = url.openConnection(); conn.setConnectTimeout(connectionTimeout); in = getInputStream(conn); in.skip(transferStatus.getBytesDownloaded()); int count = 0; System.out.println("downloading"); transferStatus.setStatus(TransferStatus.DOWNLOADING); outFile = new RandomAccessFile("build/outfile", "rw"); outFile.seek(transferStatus.getBytesDownloaded()); while ((len = in.read(buf)) > 0) { outFile.write(buf, 0, len); transferStatus.incrementBytesDownloaded(len); updateElapsedTime(); } } catch (Exception e) { System.out.println("Exception transfering data: " + e.getMessage()); } finally { if ( in != null ) { in.close(); } if ( outFile != null ) { outFile.close(); } conn = null; } } System.out.println("transfer complete"); transferStatus.setStatus(TransferStatus.COMPLETE); } -- View this message in context: http://old.nabble.com/Large-File-Transfer-tp23378044p28832355.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.