How can I recognize ActiveMQ disconnect using NMS and C#

 ̄綄美尐妖づ 提交于 2019-12-23 13:02:13

问题


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.

Is there a way using NMS(particulary Apache.NMS.IConnection or the Apache.NMS.ISession objects)

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.


回答1:


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

where m_connection is a IConnection object.

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.



来源:https://stackoverflow.com/questions/2030657/how-can-i-recognize-activemq-disconnect-using-nms-and-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!