int size = 0;
if (syMessage.getContent() instanceof StreamMessage) {
// in case the StreamMessage is passed through from JMS inbound
StreamMessage sm = syMessage.getContent(StreamMessage.class);
while ((size = sm.readBytes(buffer)) > 0) {
msg.writeBytes(buffer, 0, size);
}
} else {
InputStream is = syMessage.getContent(InputStream.class);
while ((size = is.read(buffer)) > 0) {
msg.writeBytes(buffer, 0, size);