Messages with byte[] bodies are sent as "large messages" to Artemis via camel-jms and cause ConsumerTemplate exception

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Messages with byte[] bodies are sent as "large messages" to Artemis via camel-jms and cause ConsumerTemplate exception

Florian Patzl
Hello,
I've stumbled upon behavior in Camel + Artemis JMS that I do not understand.
Camel messages with bodies of type byte[] are treated as "large messages" in Artemis - even small messages with only three bytes.
In combination with "manually" polling the messages from JMS using a Camel ConsumerTemplate, that leads to exceptions like:

Caused by: org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException: AMQ119023: The large message lost connection with its session, either because of a rollback or a closed session
        at org.apache.activemq.artemis.core.client.impl.LargeMessageControllerImpl.saveBuffer(LargeMessageControllerImpl.java:273) ~[artemis-core-client-2.6.2.jar:2.6.2]
        at org.apache.activemq.artemis.core.client.impl.ClientLargeMessageImpl.saveToOutputStream(ClientLargeMessageImpl.java:115) ~[artemis-core-client-2.6.2.jar:2.6.2]
        at org.apache.activemq.artemis.jms.client.ActiveMQMessage.saveToOutputStream(ActiveMQMessage.java:853) ~[artemis-jms-client-2.6.2.jar:2.6.2]
        at org.apache.activemq.artemis.jms.client.ActiveMQMessage.setObjectProperty(ActiveMQMessage.java:693) ~[artemis-jms-client-2.6.2.jar:2.6.2]
        at org.apache.camel.component.jms.JmsBinding.createByteArrayFromBytesMessage(JmsBinding.java:251) ~[camel-jms-2.22.1.jar:2.22.1]
        at org.apache.camel.component.jms.JmsBinding.extractBodyFromJms(JmsBinding.java:163) ~[camel-jms-2.22.1.jar:2.22.1]
        ... 21 more

The problem does not occur when converting my byte[] bodies to Byte[].
I have described the problem in more detail in the following StackOverflow question:
https://stackoverflow.com/q/59651341/827950

My minimal test setup is based on Camel 2.22.1 and Artemis 2.10.1. I have reproduced the phenomenon that Artemis handles the messages as large messages with Camel 3.0.0 as well, but I do not (yet) have a minimal example that leads to the same exception when using ConsumerTemplate for that Camel version.

Basically, I have two questions:
1) Why does Artemis treat small byte array messages sent via Camel as large messages?
2) Does Camel ConsumerTemplate support streamed large messages?

Best regards,
Florian
Reply | Threaded
Open this post in threaded view
|

Re: Messages with byte[] bodies are sent as "large messages" to Artemis via camel-jms and cause ConsumerTemplate exception

Claus Ibsen-2
The byte[] vs Byte[] is likely more of a Artemis question how their
JMS client handle this.
For byte[] then Camel creates a javax.jms.BytesMessage and for the
other it creates a javax.jmx.ObjectMessage.

You can force what JMS message type Camel should use with the option
(see its docs)
You can also turn on TRACE logging and see if you see this logging message

LOG.trace("Optimised for Artemis: Reading from BytesMessage in
streaming mode directly into CachedOutputStream payload");

It smells that this optimized mode (CAMEL-11931) somehow cause Artemis
to close the stream. (smells like a bug in Artemis).
We could maybe add an option to turn this optimized Artemis mode off.

You can also turn off mapJmsMessage then Camel does not extract
body/headers etc.

On Mon, Jan 13, 2020 at 12:59 PM Florian Patzl <[hidden email]> wrote:

>
> Hello,
> I've stumbled upon behavior in Camel + Artemis JMS that I do not understand.
> Camel messages with bodies of type byte[] are treated as "large messages" in Artemis - even small messages with only three bytes.
> In combination with "manually" polling the messages from JMS using a Camel ConsumerTemplate, that leads to exceptions like:
>
> Caused by: org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException: AMQ119023: The large message lost connection with its session, either because of a rollback or a closed session
>         at org.apache.activemq.artemis.core.client.impl.LargeMessageControllerImpl.saveBuffer(LargeMessageControllerImpl.java:273) ~[artemis-core-client-2.6.2.jar:2.6.2]
>         at org.apache.activemq.artemis.core.client.impl.ClientLargeMessageImpl.saveToOutputStream(ClientLargeMessageImpl.java:115) ~[artemis-core-client-2.6.2.jar:2.6.2]
>         at org.apache.activemq.artemis.jms.client.ActiveMQMessage.saveToOutputStream(ActiveMQMessage.java:853) ~[artemis-jms-client-2.6.2.jar:2.6.2]
>         at org.apache.activemq.artemis.jms.client.ActiveMQMessage.setObjectProperty(ActiveMQMessage.java:693) ~[artemis-jms-client-2.6.2.jar:2.6.2]
>         at org.apache.camel.component.jms.JmsBinding.createByteArrayFromBytesMessage(JmsBinding.java:251) ~[camel-jms-2.22.1.jar:2.22.1]
>         at org.apache.camel.component.jms.JmsBinding.extractBodyFromJms(JmsBinding.java:163) ~[camel-jms-2.22.1.jar:2.22.1]
>         ... 21 more
>
> The problem does not occur when converting my byte[] bodies to Byte[].
> I have described the problem in more detail in the following StackOverflow question:
> https://stackoverflow.com/q/59651341/827950
>
> My minimal test setup is based on Camel 2.22.1 and Artemis 2.10.1. I have reproduced the phenomenon that Artemis handles the messages as large messages with Camel 3.0.0 as well, but I do not (yet) have a minimal example that leads to the same exception when using ConsumerTemplate for that Camel version.
>
> Basically, I have two questions:
> 1) Why does Artemis treat small byte array messages sent via Camel as large messages?
> 2) Does Camel ConsumerTemplate support streamed large messages?
>
> Best regards,
> Florian



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2