jeanouii commented on code in PR #1728:
URL: https://github.com/apache/activemq/pull/1728#discussion_r2890707885


##########
activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java:
##########
@@ -235,6 +243,20 @@ public static interface DeliveryListener {
     private BlobTransferPolicy blobTransferPolicy;
     private long lastDeliveredSequenceId = -2;
 
+    // Single-threaded executor for async send: ensures one CompletionListener 
callback at a time
+    // and that callbacks are invoked in the same order as the corresponding 
send calls
+    // per Jakarta Messaging 3.1 spec section 7.3.8
+    private final ExecutorService asyncSendExecutor = 
Executors.newSingleThreadExecutor(
+        r -> new Thread(r, "ActiveMQ async-send"));
+
+    // Set to true on the executor thread while a CompletionListener callback 
is executing.
+    // Used to detect illegal session operations (close/commit/rollback) from 
within a callback.
+    static final ThreadLocal<Boolean> IN_COMPLETION_LISTENER_CALLBACK = 
ThreadLocal.withInitial(() -> false);
+
+    // Set to true on the dispatch thread while a MessageListener.onMessage() 
callback is executing.
+    // Used to detect illegal connection/session operations from within a 
MessageListener callback.
+    static final ThreadLocal<Boolean> IN_MESSAGE_LISTENER_CALLBACK = 
ThreadLocal.withInitial(() -> false);
+

Review Comment:
   oh man! Very good catch @gemmellr 
   Bad habit to have static thread locals. But you absolutely right, this is 
too restrictive compared to the spec that only requires per session. I'll fix 
this.  



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to