ibm-messaging / mq-mqi-nodejs

Calling IBM MQ from Node.js - a JavaScript MQI wrapper
Apache License 2.0
79 stars 42 forks source link

How to perform perform health-check on MQ connection #89

Closed creasman closed 4 years ago

creasman commented 4 years ago

This is a general question and maybe something to document if not covered in one of the samples. I have a REST service that opens a connection to MQ and then publishes content to a topic as requests are made. The connection is opened once and stays open.

The service includes a health-checker endpoint that is expected to respond with the current status. I'd like to enhance this to include the status of the MQ connection and any related information. Is there some function in this package I can call to request connection and endpoint information?

ibmmqmet commented 4 years ago

A call to any MQ verb will return failure if the connection is broken (usually a 200i9 reason code). You might use inq() aka MQINQ as something that is otherwise harmless. See the amqsinq sample program - that does an inquire on the qmgr to get its name.

But normally people do not do that kind of health-checking on a connection within an application - the connection might fail immediately after calling mqinq and then you'd get the failure indication on your next MQ operation which you'd have to deal with then anyway. The only real benefit to regular polling is that it may stop otherwise-idle connections being disconnected for inactivity reasons.

creasman commented 4 years ago

Thanks. I'll take a look at the inq() call. In this case the call is more of a diagnostic tool (not regularly polled) that's used to isolate the issue once a general problem has been detected. For example, the service in question connects to a MongoDB database and MQ. If the connection to either of these is broken it would continue to run in a limited capacity, and respond successfully to simple health check requests (polled). The next step would be to call for a deep health check and probe each dependency to see where the problem resides (non-polled).