IBM MQ XMS subscription does not close

I have an application that uses WebSphere MQ to send data through WebSphere to a data center in Cloud. Part of the functionality is that if the subscriber on the server side detects that the message has not been received within 30 minutes, the flow is suspended for 5 minutes and the connection is deleted. When it reboots, it reconnects.

In practice, I found that disconnecting did not delete the subscription. When I try to reconnect, I see this error:

“There may be a problem creating the subscription because it is being used by another user of the message. Make sure message users using this subscription are closed before trying to create a new subscription with the same name. For more information, see Related an exception.

Indicates that the message handler is still connected, which means that the disconnect failed. Disable code for the XmsClient object (part of the library, although one of my colleagues may have changed it):

public override void Disconnect() { _producer.Close(); _producer.Dispose(); _producer = null; _consumer.MessageListener = null; _consumer.Close(); _consumer.Dispose(); _consumer = null; _sessionRead.Close(); _sessionRead.Dispose(); _sessionRead = null; _sessionWrite.Close(); _sessionWrite.Dispose(); _sessionWrite = null; _connection.Stop(); _connection.Close(); _connection.Dispose(); _connection = null; //GC.Collect(); IsConnected = false; } 

Does anyone have any thoughts on why the link still exists?

+2
c # ibm-mq
source share
1 answer

From the error description, it looks like the server’s subscriber is creating a long-term subscription. Long subscription continues to receive messages, even if the subscription to the application is not running. To remove a long-term subscription, you must call Session.Unsubscribe (). Simply closing the consumer does not cancel the subscription.

If you intend to close the subscriber without canceling the subscription, then run the Connection.Stop () command, and then close the message logger and close it. Calling the connection.Stop method stops message delivery.

+3
source share

All Articles