allthingssecurity commented on code in PR #26996:
URL: https://github.com/apache/camel/pull/26996#discussion_r4128710725


##########
components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java:
##########
@@ -262,8 +262,16 @@ public Message createMessage(Session session) throws 
JMSException {
         try {
             doSend(exchange, true, destinationName, destination, 
messageCreator, messageSentCallback);
         } catch (Exception e) {
-            // send failed after reply was registered, cancel to prevent 
double callback on timeout
-            replyManager.cancelCorrelationId(registeredCorrelationId[0]);
+            // send failed after the reply was registered: cancel it to 
prevent a second callback from the timeout
+            String registered = registeredCorrelationId[0];
+            if (registered != null && 
!replyManager.cancelCorrelationId(registered)) {

Review Comment:
   Fixed in dc23b03a7. The `MessageSentCallback` that `processInOut` passes for 
`useMessageIDAsCorrelationID` now wraps 
`UseMessageIdAsCorrelationIdMessageSentCallback` and, once `sent()` has moved 
the handler, sets `registeredCorrelationId[0]` to the JMSMessageID. A failure 
after that point (the commit of a transacted session) therefore cancels the id 
the handler actually sits under. If the timeout had already evicted the 
provisional id, `updateCorrelationId` doesn't move anything, so the cancel of 
the new id returns `false` and the timeout keeps ownership, same as before.
   
   New test 
`testCallbackInvokedOnceWhenCommitFailsAfterMessageIdCorrelationUpdate` uses 
`useMessageIDAsCorrelationID=true&transactedInOut=true&requestTimeout=3000` and 
a proxied session whose `commit()` throws. It asserts that the exchange fails 
promptly (< 3s) with the commit exception and not `ExchangeTimedOutException`, 
that there's exactly one `onFailure` and no later timeout completion, and that 
nothing is left inflight. Without the `JmsProducer` change it fails with 
`ExchangeTimedOutException` after the 3s timeout.
   
   _Claude Code on behalf of allthingssecurity_
   



-- 
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