问题描述
我有一个C#发布者和订阅者,他们使用ActiveMQ和NMS互相交谈。一切正常,除非我无法知道ActiveMQ何时崩溃。这对消费者而言尤其不利。他们停止获取数据,但是除了数据停止显示之外,没有引发任何错误或事件。
I have a C# publisher and subscriber that talk to each other using ActiveMQ and NMS. Everything works fine, except I have no way to know when ActiveMQ goes down. This is particularly bad for the consumer. They stop getting data, but aside from the fact that data stops showing up, no errors or events are raised.
是否可以使用NMS(特别是Apache.NMS。 IConnection或Apache.NMS.ISession对象)
Is there a way using NMS(particulary Apache.NMS.IConnection or the Apache.NMS.ISession objects)
我从Spring下载了我正在使用的实现,但是我没有使用任何特定的spring实现,
I downloaded the implementation that I'm using from Spring, but I'm not using any specific spring implementations, everything I'm using is in the Apache.NMS and Apache.NMS.ActiveMQ namespaces.
推荐答案
嗯,自此以来,已经有很多东西了。 m using是在Apache.NMS和Apache.NMS.ActiveMQ命名空间中。问题已经提出,但是现在您有几个可用的事件:
Well, it's been a lot since this question has been asked, but now you have several events available:
m_connection.ConnectionInterruptedListener += new ConnectionInterruptedListener(OnConnectionInterruptedListener);
m_connection.ConnectionResumedListener += new ConnectionResumedListener(OnConnectionResumedListener);
m_connection.ExceptionListener += new ExceptionListener(OnExceptionListener);
其中m_connection是IConnection对象。
where m_connection is a IConnection object.
通过这3个事件,您将能够找到您的经纪人何时倒闭(以及其他有用的信息,例如何时恢复连接或他遇到异常)
With these 3 events you will be able to find when your broker is down (among other usefull information, such as when it resumes the connection or when he encounters an exception)
注意:如果处于故障转移模式,这些异常将被故障转移传输层吞没并自动处理。因此,您不会收到任何此类事件。
Note: If you are in failover mode, these exceptions will be swallowed by the failover transport layer and handled automatically with them. Hence you will not receive any of these events.
这篇关于如何使用NMS和C#识别ActiveMQ断开连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!