Sun GlassFish Message Queue 4.4 Developer's Guide for C Clients


The MQCloseConnection function closes the connection to the broker.

MQCloseConnection(MQConnectionHandle connectionHandle);

Return Value

MQStatus. See the MQStatusIsError() function for more information.



The handle to the connection that you want to close. This handle is created and passed back to you by the function MQCreateConnection.

Closing the connection closes all sessions, producers, and consumers created from this connection. This also forces all threads associated with this connection that are blocking in the library to return.

Closing the connection does not actually release all the memory associated with the connection. After all the application threads associated with this connection (and its dependent sessions, producers, and consumers) have returned, you should call the MQFreeConnection() function to release these resources.

Common Errors

MQ_CONCURRENT_DEADLOCK (If the function is called from an exception listener or a consumer’s message listener.)

MQ_ILLEGAL_CLOSE_XA_CONNECTION (If called to claose an XA connection.)