Hi,
I am using Camel to connect to ActiveMQ and it fails to shutdown when the
ActiveMQComponent cannot make a connection to the broker with the failover
protocol (activemq version 5.12.0).
The problem seems to be that the failover transport tries to connect to the
broker in an endless loop on its own thread that cannot be interrupted. I think
the problem is in the PooledTaskRunner: there is a shutdown field which is set
to true when camel shuts down, but it appears as false to the thread that is
running the endless loop.
I am currently at a loss what to do. I want to keep the maximum retries setting
for the failover transport on indefinite, since I do not know when the the
broker is back online. At the same time, it has to be possible to shut down the
application even if there never was a connection to the ActiveMQ broker.
Has anybody seen this problem before and can give some advice? Is this a bug in
ActiveMQ?
Attached there is some code that reproduces the problem - it never terminates.
Regards,
Anna
The code:
public class ShutdownBug {
public static void main(String[] args) throws Exception {
DefaultCamelContext camelContext = new DefaultCamelContext();
ActiveMQComponent activeMQComponent = new ActiveMQComponent();
activeMQComponent.setBrokerURL("failover:(http://localhost:61616)");
camelContext.addComponent("activemq", activeMQComponent);
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() {
from("activemq:queue:myqueue").to("stream:out");
}
});
Thread startThread = new Thread(new Runnable() {
@Override
public void run() {
try {
camelContext.start();
}
catch (Exception e) {
e.printStackTrace();
}
}
});
startThread.start();
startThread.interrupt();
startThread.join();
camelContext.stop();
}
}