jmsindexoutofboundsexceptionactivemq-artemisamq

AMQ Error reading in simpleString, length=xxx is greater than readableBytes=yyy


I'm trying to work out how to fix this ActiveMQ Artemis error.

Seems the occasional message is too big for SimpleString, and isn't sending, and it goes to the DLQ.

java.lang.IndexOutOfBoundsException: Error reading in simpleString, length=1366648 is greater than readableBytes=127646@ClientLargeMessageImpl[messageID=578576793, durable=true, address=AuthCorrespondence.sendmail,userID=7f72137c-c3a3-11eb-87f7-0242c0a8e003,properties=TypedProperties[__AMQ_CID=b3f70eb1-be3c-11eb-87f7-0242c0a8e003,_AMQ_LARGE_SIZE=127651,_AMQ_ROUTING_TYPE=1]]
    at org.apache.activemq.artemis.jms.client.ActiveMQMessageConsumer.getMessage(ActiveMQMessageConsumer.java:234)
    at org.apache.activemq.artemis.jms.client.ActiveMQMessageConsumer.receive(ActiveMQMessageConsumer.java:132)
    at org.springframework.jms.support.destination.JmsDestinationAccessor.receiveFromConsumer(JmsDestinationAccessor.java:130)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveMessage(AbstractPollingMessageListenerContainer.java:416)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:302)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:255)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1168)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1160)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1057)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IndexOutOfBoundsException: Error reading in simpleString, length=1366648 is greater than readableBytes=127646
    at org.apache.activemq.artemis.api.core.SimpleString.readSimpleString(SimpleString.java:183)
    at org.apache.activemq.artemis.api.core.SimpleString.readSimpleString(SimpleString.java:171)
    at org.apache.activemq.artemis.api.core.SimpleString.readNullableSimpleString(SimpleString.java:158)
    at org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper.readNullableSimpleString(ChannelBufferWrapper.java:69)
    at org.apache.activemq.artemis.reader.TextMessageUtil.readBodyText(TextMessageUtil.java:37)
    at org.apache.activemq.artemis.jms.client.ActiveMQTextMessage.doBeforeReceive(ActiveMQTextMessage.java:112)
    at org.apache.activemq.artemis.jms.client.ActiveMQMessageConsumer.getMessage(ActiveMQMessageConsumer.java:228)
    ... 11 more

The most likely issue I can see is the similarity between readableBytes=127646 and _AMQ_LARGE_SIZE=127651.

From the docs, though, this _AMQ_LARGE_SIZE is the threshold for Large Messages, and it is supposed to be 2GB, and this message is what, 1.36MB?

What's going on?

EDIT:

[root@6dcbad102045 large-messages]# pwd
/opt/amq/broker/data/large-messages

[root@6dcbad102045 large-messages]# ls -l
total 13828
-rw-r--r-- 1 root root 6451200 Sep 14  2020 194154444.msg
-rw-r--r-- 1 root root 4198400 Nov  5  2020 266358970.msg
-rw-r--r-- 1 root root 1843200 Nov 13  2020 277265384.msg
-rw-r--r-- 1 root root 1433600 Apr 28 12:36 522483226.msg
-rw-r--r-- 1 root root  102400 Jun  2 15:07 578576791.msg
-rw-r--r-- 1 root root  127651 Jun  3 09:46 579961682.msg

I'm in Fuse/OSGi. 2.6.3.redhat-00015 for ActiveMQ Artemis JMS Client OSGi. 2.21.5 for camel-amqp. I can't work out what Artemis version it is. There's 1000+ successful deliveries. Just 6 fails.


Solution

  • The 2.6.3.redhat-00015 version corresponds to AMQ 7.2.3 which is quite old at this point. The current AMQ release is 7.8.1. I strongly recommend you upgrade as it's likely you're hitting a bug that's already been fixed.

    You may be able to work around the issue by increasing the minimum large message size (e.g using minLargeMessageSize on core client URLs or amqpMinLargeMessageSize on your AMQP acceptor). For what it's worth, the stack-trace indicates that the core JMS client (i.e. not AMQP) is in use when the exception is thrown.

    Lastly, it's worth noting that the default minimum large message size is 100 KB not 2 GB as explained in the documentation.