Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What Happens to JMS Listener if JMS Server goes down?

 
Gul Khan
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Some confusion about this, need help. If I have a JMS Listener client at a client machine listening to a Queue on JMS Server. The JMS Server goes down! what will happen to the Listener?
1- Will it throw exception?
2- It will keep listening to nothing? i.e. the JMS Listener client will never know the Server is down?

If the listener will never know about the server being down then:

1- Will it start receiving the messages as soon as the Server comes up? i.e. the connection is never lost?

2- Will have to restart the listener? In that case how can the client JMS Listener ever know when to reconnect?

Thanks for the help in advance.
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm assuming you're talking about javax.jms.MessageListener here. If your server goes down, the listener wouldn't know a thing, since it's only concerned with messages actually being consumed (since none are at that point, it's oblivious to the situation). You should check into using javax.jms.ExceptionListener. Note that the spec says that JMS providers should attempt to correct problems before propogating the exception to the ExceptionListener. Assuming you have a nice provider, it would reconnect so your MessageListener works as expected. But do check your JMS provider's documentation.

As for your "middle" question .... as long as your subscriber is durable you shouldn't have any issues. You can read all about the durability issues in the spec or somewhere else -- I read the O'Reilly JMS book -- run reading.
 
Gul Khan
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Nathanial, I will think along the lines. I am using MQ Series by the way.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic