Reputation: 1278
I want to check the connection in MQ (if its online/offline) using java. Could someone point me in the right direction / perhaps have example code for me to look at. What is the best way of approaching this?
Upvotes: 0
Views: 3048
Reputation: 15263
The best approach in my opinion is to make the intended MQ function call and handle the exception that is returned if connection is not available. For example you want to make MQQueue.Put
call and you are not sure whether the connection is ON or not. You can go ahead and make the call. If a connection is not available you will get a 2009 - connection broken exception. Your application needs to handle this exception and re-establish the connection.
Remember a connection might be ON before issue a MQ call but can break when the call was actually issued. So it is always better to issue MQ call and handle any exceptions.
Upvotes: 1
Reputation: 399
Did you look at the link below
http://java-brew.blogspot.com/2011/01/java-code-to-connect-to-mq.html
Upvotes: 0