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/29 12:16:00 UTC

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

     [ https://issues.apache.org/jira/browse/CAMEL-16762?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Freeman Yue Fang resolved CAMEL-16762.
--------------------------------------
    Resolution: Fixed

> camel-jms - 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
>            Assignee: Freeman Yue Fang
>            Priority: Major
>             Fix For: 3.11.1, 3.12.0
>
>
> 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 read the msg 3 times to ensure we've consumed all 3 buffers.
> In the JmsBinding, we send jms stream message as
> {code}
> while (len >= 0) {
>                             count++;
>                             len = is.read(buffer);
>                             if (len >= 0) {
>                                 size += len;
>                                 LOG.trace("Writing payload chunk {} as bytes in StreamMessage", count);
>                                 message.writeBytes(buffer, 0, len);
>                             }
>                         }
> {code}
> so writeBytes multiple times, so on the consumer side we should take this into account.
> Currently it's not this case in StreamMessageInputStream(which is the consumer side to read jms stream message) 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)