I'm trying to implement a monitoring service for an ActiveMQ server. There I have implemented a polling service to connect to the ActiveMQ server periodically and do a queue browse operation to do a health check on ActiveMQ Server.
Here is the code snippet that I use to start the connection.
ActiveMQSslConnectionFactory connectionFactory = new ActiveMQSslConnectionFactory(amqUrl);
connectionFactory.setTrustStore(amqSslTrustStorePath);
connectionFactory.setTrustStorePassword(amqSslTrustStorePasswd);
connectionFactory.setKeyStore(amqSslKeyStorePath);
connectionFactory.setKeyStorePassword(amqSslKeyStorePasswd);
Connection connection = connectionFactory.createConnection(amqUser, amqPasswd);
connection.start();
The issue is when the server is unavailable the connection.start()
call hangs without throwing an error. For the monitoring purpose I need to detect this.
Am I doing anything wrong here or is there any better way to do this?
UPDATE: This happens only when I use a failover based ActiveMQ url (eg: failover:(ssl://192.168.1.112:61617,ssl://192.168.1.112:61619)?randomize=false
otherwise it does work as expected, that is it throws a JMSException (eg: ssl://192.168.1.112:61617
)