You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Freeman Yue Fang (Jira)" <ji...@apache.org> on 2021/06/28 20:00:07 UTC

[jira] [Created] (CAMEL-16762) Only the first payload chunk will be read when using jmsMessageType=Stream

Freeman Yue Fang created CAMEL-16762:
----------------------------------------

             Summary: Only the first payload chunk will be read when using jmsMessageType=Stream
                 Key: CAMEL-16762
                 URL: https://issues.apache.org/jira/browse/CAMEL-16762
             Project: Camel
          Issue Type: Bug
          Components: came-jms
            Reporter: Freeman Yue Fang


Only the first payload chunk(128K, the size of FileUtil.BUFFER_SIZE) will be read when using jmsMessageType=Stream and if the payload is bigger than 128K,  the extra part will be discarded.

In the AMQ  ActiveMQStreamMessage[doc|https://activemq.apache.org/maven/apidocs/org/apache/activemq/command/ActiveMQStreamMessage.html], we can see
{code}
A StreamMessage object is used to send a stream of primitive types in the Java programming language. It is filled and read sequentially.
{code}
So if I read and understand it correctly, for each send on the producer side we need a read on the consumer side.
For example, on the producer side
{code}
StreamMessage msg = session.createStreamMessage();
msg.writeString("Thriller");
msg.writeInt(1982);
msg.writeDouble(110.3);
{code}

and on the consumer side, we should have
{code}
// Read message
String title = msg.readString();  // must be read in the same order as written
int releaseYear = msg.readInt();
double millionsSold = msg.readDouble();
{code}

And here comes the tricky/vague part of this API, if on the producer side we have
{code}
StreamMessage msg = session.createStreamMessage();
msg.writeBytes(buffer);
msg.writeBytes(buffer);
msg.writeBytes(buffer);
{code}
Then on the consumer side we should have the msg 3 times to ensure we've consumed all 3 buffers.

Currently it's not this case in StreamMessageInputStream and hence if jmsMessageType=Stream is used(or setStreamMessageTypeEnabled(true)) and the payload is bigger than 128K, only the first 128K will be read at consumer side



--
This message was sent by Atlassian Jira
(v8.3.4#803005)