activemq-artemis icon indicating copy to clipboard operation
activemq-artemis copied to clipboard

ARTEMIS-5483: New option - jmsMaxTextMessageSize

Open AlexejTimonin opened this issue 7 months ago • 0 comments

Adds a new configuration option for Jakarta client consumers. When this configuration is set, the consumer will throw a javax.jms.JMSException on receiving large text(type 3) message that would exceed the specified size (in bytes) when creating javax.jms.TextMessage

jmsMaxTextMessageSize is intended to prevent consumers of javax.jms.TextMessage from crashing due to out-of-memory when receiving messages that are larger than consumers memory.

The configuration is provided as a URL property when establishing a connection to the broker.

Example: Throw on large text messages exceeding 10MB in size: tcp://localhost:61616?jmsMaxTextMessageSize=10000000

Note: This option relies on how core client consumer works. When message is above certain size threshold (default 100KB) it will be considered as a large message and be delivered in parts with headers first. With the help of headers we're able to determine the size of the incoming body and reject if it is above jmsMaxTextMessageSize.

If the message is below large message threshold then this option has no real defensive effect since the message will be read into memory anyway.

AlexejTimonin avatar May 18 '25 12:05 AlexejTimonin