Croway opened a new pull request, #30206:
URL: https://github.com/apache/camel/pull/30206

   JIRA: [CAMEL-27051](https://issues.apache.org/jira/browse/CAMEL-27051)
   
   The camel-sjms counterpart of CAMEL-27014 (#30164), as suggested in the 
review of that PR.
   
   - `SjmsTemplate.receive` committed the session (or acknowledged the message) 
and closed the consumer, the session and the connection before it returned the 
message, and `SjmsMessage` reads the body lazily. So `pollEnrich` and a 
`ConsumerTemplate` read the body after the connection was closed: the body of 
an ActiveMQ Artemis large message failed with `AMQ219023`, and with 
`transacted=true` or `CLIENT_ACKNOWLEDGE` a message whose body could not be 
read (such as an `ObjectMessage` while `objectMessageEnabled` is `false`) was 
committed or acknowledged, so it was lost.
   - New `SjmsTemplate.receive(..., Function<Message, T>)` applies the function 
to the message before the commit or acknowledge, and before the close. If the 
function fails, a transacted session is rolled back and a client acknowledge 
session is recovered (a failure of that is added as suppressed), as in 
camel-jms. The existing `receive` delegates to it with the identity function.
   - `SjmsPollingConsumer` creates the exchange and reads the body and the 
headers in that function. camel-sjms2 uses the same polling consumer.
   - Docs: "Message Content" section of the sjms page (and its catalog copy), 
including that the body is not read at receive time with `mapJmsMessage=false` 
and for a `StreamMessage`.
   
   Tests: `SjmsPollingConsumerLargeMessageTest` (new, embedded Artemis with 
`minLargeMessageSize=1024`). Before the fix 7 of 9 fail: the large message 
cases (`ConsumerTemplate`, selector, `pollEnrich`, `transacted`, 
`CLIENT_ACKNOWLEDGE`) with `AMQ219023`, and the unreadable message cases 
because the receive does not fail. A separate check on main confirmed that the 
unreadable message was committed and no longer on the queue. The controls 
(small message, route consumer) pass before and after. After the fix all 9 
pass; the camel-sjms tests (223, 5 skipped) and `Sjms2ToDSendDynamicTest` pass.
   
   `SjmsObjectMessageEnabledTest.testConsumerRefusesObjectMessageByDefault` is 
updated, as `JmsObjectMessageEnabledTest` was in #30164: the `ObjectMessage` is 
still refused with the same `IllegalStateException`, but the receive itself now 
fails, instead of returning an exchange whose body fails when it is read (after 
the message was already committed or acknowledged). `SjmsPollingConsumer` 
already wrapped the errors of the receive in a `RuntimeCamelException`, and 
still does, so the `IllegalStateException` is its cause.
   
   Upgrade guide: new 4.24 entry "camel-sjms, camel-sjms2 - pollEnrich and 
ConsumerTemplate read the message before they close the session".
   
   _Claude Code on behalf of Federico Mariani_
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to