How to learn how to disable ActiveMQ using NMS and C #

I have a C # publisher and subscriber who are talking to each other using ActiveMQ and NMS. Everything is working fine, except that I have no way of knowing when ActiveMQ goes down. This is especially bad for the consumer. They stop receiving data, but in addition to the fact that the data stops being displayed, no errors or events occur.

Is there a way to use NMS (especially Apache.NMS.IConnection or Apache.NMS.ISession objects)

I downloaded the implementation that I use from Spring, but I do not use any specific spring implementations, everything I use is in the Apache.NMS and Apache.NMS.ActiveMQ spaces.

+3
source share
1 answer

Well, that was a lot since this question was asked, but now you have a few events available:

m_connection.ConnectionInterruptedListener += new ConnectionInterruptedListener(OnConnectionInterruptedListener);
m_connection.ConnectionResumedListener += new ConnectionResumedListener(OnConnectionResumedListener);
m_connection.ExceptionListener += new ExceptionListener(OnExceptionListener);

where m_connection is an IConnection object.

With these three events, you can find when your broker is down (among other useful information, for example, when it resumes a connection or when it encounters an exception)

Note. If you are in the transition mode to another resource, these exceptions will be swallowed by the transshipment transport layer and automatically processed along with them. Therefore, you will not receive any of these events.

+2
source

Source: https://habr.com/ru/post/1727809/


All Articles