Author |
Message
|
gstasica |
Posted: Wed Sep 01, 2010 11:57 am Post subject: messageConsumer doesn't throw except. when connection broken |
|
|
Newbie
Joined: 12 Aug 2010 Posts: 4
|
hi,
while trying to implement reconnect feature for my MQ 7.0.1.2 client i came across situation that despite unplugging MQ server from the network my remote clients i.e. MessegeConsumers (messegeConsumer.receiveNoWait() method) don't throw any exceptions. I would assume that once the cable has been unplugged every call to this method would throw some exception.
In my application i use 100 client threads being connected to a different queue but sharing the same connection object (every thread gets its own session object thought). If i register exceptionlistener on a connection object and unplug MQ after about 3 minutes exceptionlistener gets called but this doesn't have any impact on the messegeConsumer.
How is it possible that despite connection being broken messegeConsumers don't see it? What would be the best approach of implementing reconnect feature ? |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Sep 01, 2010 2:20 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You have to use an ErrorListener and an ExceptionListener. They attach to the connection.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
gstasica |
Posted: Thu Sep 02, 2010 12:45 am Post subject: |
|
|
Newbie
Joined: 12 Aug 2010 Posts: 4
|
thanks for your reply,
what ErrorListener do you mean as one can only setExceptionListener on a connection object which i do?
The other question is why my message consumers don't throw exceptions when their connection to the server has been broken (making a messageConsumer.receiveNoWait() method call doesn't make any sense here as obviously i won't read anything) |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Sep 02, 2010 8:00 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
OK so let's rollback a little.
You have a connection with ErrorListener.
You retrieve a message with no wait and you are unhappy that you did not receive an exception...
- On the receive nowait there was no bitstream so the program just goes on --- standard behavior
- The error listener does get the error but only according to the time outs you have defined for the lower level protocols (TCP/IP)
Ok. So I do not quite understand what your problem is. As long as TCP/IP has not identified the fact that the connection is broken, your ErrorListener will not receive any error. This is standard behavior. Once the lower level protocol has notified the event, you will receive an error and the receivenowait() should also fire an exception.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
JLRowe |
Posted: Fri Sep 03, 2010 2:38 am Post subject: |
|
|
 Yatiri
Joined: 25 May 2002 Posts: 664 Location: South East London
|
turn on keepalive, this will let your client know when the connection has been broken |
|
Back to top |
|
 |
|