0

Using the 1.6 version of NMS (1.6.3 activemq) I'm setting up a listener to wait for messages. The listener has a thread of it's own (not mine) and my code get out of scope (until the listener's function is being called).

If the ActiveMQ server disconnects, I get a global exception which I can only catch globally. (my thread that created the listener will not catch it. I have nothing to wrap with "try" and "catch").

Is there a way to set a callback function like - OnError += ErrorHandlingFunction() as I use the listener to deal with this issue in a local way and not by global exception catcher ? Is there a better way to deal with this issue (I can't use Transport Failure as I don't have any other options, but to wait a while, and disconnect, maybe log something or send a message that the server is offline).

Dani
  • 14,639
  • 11
  • 62
  • 110

1 Answers1

0

There is no mechanism in the client for hooking in the async message listener to find out if the connection dropped during the processing of a message. You should really examine why you think you need such a thing there.

NMS API methods you use in the async callback will throw an exception when not connected so if you did something like try to ACK a message in the async message event handler then it would throw an exception if the connection was down.

Tim Bish
  • 17,475
  • 4
  • 32
  • 42
  • All I need to do is to turn off the server and I get and exception, I did find a way to catch it, through the connection object. it has what I need - I will post it here tomorrow as I'm not at work today – Dani Oct 22 '14 at 01:55