Federico Mariani created CAMEL-27014:
----------------------------------------

             Summary: camel-jms - pollEnrich and ConsumerTemplate read the body 
after the JMS session is closed, so an Artemis large message cannot be read
                 Key: CAMEL-27014
                 URL: https://issues.apache.org/jira/browse/CAMEL-27014
             Project: Camel
          Issue Type: Bug
          Components: camel-jms
            Reporter: Federico Mariani


The JMS polling consumer (used by {{pollEnrich}} and {{ConsumerTemplate}}) 
receives the message with {{JmsTemplate.receive()}}, which closes the JMS 
consumer and session before it returns. The body is read later, when the 
exchange first uses it. 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}}. It fails the same way with 
{{artemisStreamingEnabled=true}}. A route that consumes from the same queue 
reads the body, as it reads it while the session is open.

{code:java}
template.sendBody("jms:queue:big", new byte[200_000]);

Exchange exchange = consumer.receive("jms:queue:big", 5000);
exchange.getIn().getBody(byte[].class); // AMQ219023

from("direct:start")
    .pollEnrich("jms:queue:big", 5000) // Error occurred during aggregation, 
caused by AMQ219023
    .to("mock:result");
{code}

With {{transacted=true}} the session is committed before the body is read, so a 
message whose body cannot be read is lost.

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 and the session.

_Claude Code on behalf of Federico Mariani_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to