IBM MQ XMS订阅未关闭 [英] IBM MQ XMS subscription not closing

查看:76
本文介绍了IBM MQ XMS订阅未关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用WebSphere MQ通过WebSphere将数据发送到Cloud中的数据中心的应用程序.该功能的一部分是,如果服务器端订户检测到30分钟未收到消息,则线程将暂停5分钟,然后删除连接.重新启动后,它会重新连接.

I have an application that uses WebSphere MQ to send data through WebSphere to a datacentre in the Cloud. Part of the functionality is that if the server-side subscriber detects that a message has not been received for 30 minutes, the thread is paused for 5 minutes, and the connection is removed. When it restarts, it reconnects.

实际上,我发现断开连接并没有删除订阅.尝试重新连接时,我看到此错误:

In practice, I've found that disconnecting has not removed the subscription. When attempting to reconnect, I see this error:

由于其他消息使用者正在使用订阅,因此创建订阅时可能会出现问题. 在尝试使用相同的名称创建新的订阅之前,请确保使用此订阅的所有消息使用者均已关闭.请参阅链接的异常以获取更多信息."

"There may have been a problem creating the subscription due to it being used by another message consumer. Make sure any message consumers using this subscription are closed before trying to create a new subscription under the same name. Please see the linked exception for more information."

这表明消息处理程序仍处于连接状态,这意味着断开连接失败.断开XmsClient对象(虽然是我的一位同事可能已经更改了该库的一部分)的代码,但它是:

This shows the message handler is still connected, meaning disconnect has failed. Disconnect code for the XmsClient object (part of the library, although one of my colleagues might have changed it) is:

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;
        }

有人对为什么连接仍然存在有任何想法吗?

Anyone have any thoughts as to why the connection still exists?

推荐答案

从错误描述中可以看出,服务器订阅者正在创建持久订阅.即使订阅应用程序未运行,持久订阅仍会继续接收消息.要删除持久订阅,您必须调用Session.Unsubscribe().仅仅关闭使用者并不会删除订阅.

From the error description it looks like server subscriber is creating a durable subscription. Durable subscription continues to receive messages even when subscribing application is not running. To remove a durable subscription you must call Session.Unsubscribe(). Simply closing the consumer does not remove subscription.

如果您打算关闭订阅者而不删除订阅,请先发出Connection.Stop(),然后注销消息侦听器,然后关闭使用者.调用connection.Stop方法停止消息传递.

If your intention was to close a subscriber without removing the subscription, then issue Connection.Stop() first followed by deregister message listener and then close consumer. Calling connection.Stop method stops message delivery.

这篇关于IBM MQ XMS订阅未关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆