• Post Reply Bookmark Topic Watch Topic
  • New Topic

JMS and acknowledging group of messages  RSS feed

 
kavithakaran kanapathippillai
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to process a group of messages together and acknowledge when I receive the last message in a group.

Say I have 10 messages in a group and I have a header property to identify the last message in that group. When I receive the last message I would call the acknowledge() method.

But I feel I might get stuck in an indefinite loop.
Say JMS provider issues first 5 messages and since hasn't received any acknowledgment (I will only acknowledge the 10th one), start Redelivering the messages 1-5 again and again.

Would this happen? How this kind of scenario is handled?

Appreciate any help.

 
Pallav Bora
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you acknowledge the last message in a group all other messages belonging to the group gets acknowledged automatically
 
kavithakaran kanapathippillai
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pallav Bora wrote:When you acknowledge the last message in a group all other messages belonging to the group gets acknowledged automatically


Whether the messages belongs to one group or not, acknowledging one message acknowledges all previously received messages by that session that received this message.

My question is not that. I put it in this way.

How many unacknowledged messages JMS provider will wait for before start redelivering the unacknowledged messages?
or
How long JMS provider will wait before start redelivering them?
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How many unacknowledged messages JMS provider will wait for before start redelivering the unacknowledged messages?


Assuming you are using client acknowledge, unacknowledged messages will not be redelivered automatically. They will only when the server is restarted or an explicit call to session.recover() is made.

cheers,
ram.
 
kavithakaran kanapathippillai
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ram. It clears lot of confusion I had in understanding JMS.

After thinking of your answer, I assume the following. Please correct me if I am wrong.

With Client acknowledge
1) If the onMessage() method completes successfully without any exception thrown but client didn't call the acknowledge method.
In this case, unacknowledged messages will be delivered only when the server is restarted or an explicit call to session.recover() is made.

2)If the onMessage() method didn't finish successfully. In this case server can redeliver it without a restart or an explicit call to session.recover().

 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello kavithakaran,

With Client acknowledge
1) If the onMessage() method completes successfully without any exception thrown but client didn't call the acknowledge method.
In this case, unacknowledged messages will be delivered only when the server is restarted or an explicit call to session.recover() is made.

2)If the onMessage() method didn't finish successfully. In this case server can redeliver it without a restart or an explicit call to session.recover().


In both the cases redelivery is not automatic and you have to call recover() for message redelivery. If you think about it it makes sense because it is the client's responsibility to acknowledge messages. Even if onMessage() did not finish succesfully, the client has to catch the exception and make a decision on acknowledgement.

cheers,
ram.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!