IBM JMS connection
I'm currently working in C# and I need to check the state of the JMS connection that i made (开发者_开发技巧whether it's connected / disconnected). I'm sure that I can connect and disconnect succesfully..its just that i need to display the status of the connection in my UI.
Is there any properties of the JMS connection that states connection status? Or is there any other method that i can use to check the connection status?
Thanks for your help. :)
Currently, I'm using the ExceptionListener to listen for any exceptions and a flag will be set to false when any exception is catched. And when I'm connecting, I will set the flag to true vice versa when i disconnect, I will set the flag to false.
This flag will be used by my UI to detect whether the connection is up or not.
However I was thinking that if theres any property / methods of the IBM connection which can be used to show the state of the connection as its a much better solution. For SonicMQ, theres .getConnectedState() which shows whether the connection is active or inactive. I was wondering whether if IBM have something similar to SonicMQ?
You can use the Connection.setExceptionListener() method to be notified asynchronously of exceptions detected in the connection. If a problem is detected the onException()
method is called.
Be sure to set the FAILIFQUIESCE property on the factories and destinations so that your connection is notified and closed in an orderly fashion when the QMgr is shut down by the administrator.
In v7 of WMQ it is possible so enable session reconnection in the transport. In this case, the application may not be aware that the connection was interrupted but you can treat it as having been continuously connected.
Note that, for the most part, exceptions are driven by the application's API calls. So if the connection is lost, you may not know about it in real time but rather find out when an API call is made. If the application sits idle for long periods of time and you want a real-time display of connection status. Please see also "How to find out if JMS Connection is there?" for more on that topic.
WMQ v7 has options to reconnect the client automatically. You must be using v7 at both the client and the server for this to work. Since v6 is end-of-life as of Sept 2011, it is best if you develop this app on v7. You can download the v7 client as SupportPac MQC7. When JMS client reconnect is enabled, the application may not be aware of the connection activity except as a delay in responding to an API call while the connection is rebuilt. The length of that delay depends on channel tuning set by the administrator and in the connection factory.
精彩评论