ruthst00 commented on issue #2849: URL: https://github.com/apache/activemq/issues/2849#issuecomment-6975803564
@muskaan62 There are two separate concerns here: **isolating failures** and **recovering from a failed connection**. - **For isolation**, use separate physical connections for workloads that must not affect one another—for example, one for the producer and another for the consumer. You do not necessarily need one connection per session; sessions can share a connection where sharing its failure boundary is acceptable. If using a connection pool, make sure these are genuinely separate underlying connections. - **For recovery**, once this particular interruption has caused the connection to fail, replace that connection **and recreate its sessions, producers, and consumers**. Creating another session on the failed connection will not recover it. A connection manager or framework can manage that replacement rather than your application doing it manually. However, **do not recreate the connection after every `IOException` or `JMSException` indiscriminately**. Recoverable broker/network failures can be handled by the failover transport. The case discussed here—interrupting an application thread while it waits for a synchronous response—explicitly fails the shared connection through [`FutureResponse` and `ResponseCorrelator`](https://github.com/apache/activemq/tree/main/activemq-client/src/main/java/org/apache/activemq/transport). For your example, I would also avoid using `Thread.interrupt()` as the normal way to stop a worker while it is inside a JMS operation. Prefer cooperative shutdown, such as a stop flag and a bounded `receive(timeout)`, letting any in-flight send finish before closing that worker’s resources. Finally, a failed/interrupted send does not necessarily mean the broker did not receive the message. Any application-level retry should account for possible duplicates. -- 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
