可以说,在通过 Apache NMS(使用 ActiveMQ)传输大文件时,当前被认为是最先进的是什么?将整个内容放入 StreamMessage 中?然而,我发现这里的命名有点误导,因为文件实际上并不是通过 JMS 进行流式传输,整个内容将驻留在内存(或磁盘?)中,并将一次全部发送。我在处理大于 100 MB 的文件时遇到了一些问题:
Apache.NMS.NMSException : Unable to write data to the transport connection: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full
。
NMS 不支持BlobMessage
。我真的没有其他选择,只能将文件分成块,在另一侧重新组装它们,等等。
使用GZIPInputStream怎么样, 例如 : GZIPInputStream inputStream = new GZIPInputStream(new ByteArrayInputStream(gzipped));