Federico Mariani created CAMEL-27051:
----------------------------------------
Summary: camel-sjms - pollEnrich and ConsumerTemplate read the
body after the JMS session is closed, so an Artemis large message cannot be read
Key: CAMEL-27051
URL: https://issues.apache.org/jira/browse/CAMEL-27051
Project: Camel
Issue Type: Bug
Components: camel-sjms
Reporter: Federico Mariani
Fix For: 4.24.0
The SJMS polling consumer (used by {{pollEnrich}} and {{ConsumerTemplate}})
receives the message with {{SjmsTemplate.receive}}, which commits the session
(or acknowledges the message) and closes the consumer, the session and the
connection before it returns. The body is read later, when the exchange first
uses it ({{SjmsMessage}} reads it lazily). The ActiveMQ Artemis client streams
the body of a large message (above {{minLargeMessageSize}}, 100 KiB by default)
through the consumer, so the body can no longer be read: it fails with
{{AMQ219023: The large message lost connection with its session, either because
of a rollback or a closed session}}. A route that consumes from the same queue
reads the body, as it reads it while the session is open.
{code:java}
template.sendBody("sjms:queue:big", new byte[200_000]);
Exchange exchange = consumer.receive("sjms:queue:big", 5000);
exchange.getIn().getBody(byte[].class); // AMQ219023
from("direct:start")
.pollEnrich("sjms:queue:big", 5000) // Error occurred during aggregation,
caused by AMQ219023
.to("mock:result");
{code}
With {{transacted=true}} (or {{acknowledgementMode=CLIENT_ACKNOWLEDGE}}) the
session is committed (or the message acknowledged) before the body is read, so
a message whose body cannot be read is lost: for example an {{ObjectMessage}}
while {{objectMessageEnabled}} is {{false}} fails when the exchange reads the
body, and the message is no longer on the queue.
Expected: the polling consumer reads the body and the headers of the message
before it acknowledges the message (or commits the session) and closes the
consumer, the session and the connection. If the body cannot be read, the
receive fails, and the session is rolled back (or recovered), so the message is
delivered again.
This is the camel-sjms counterpart of CAMEL-27014 (camel-jms).
_Claude Code on behalf of Federico Mariani_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)