Is a message on a queue will only be received by one and only one consumer? What happens if for example a consumer receives a message but does not send back the ack?

Is a message on a queue will only be received by one and only one consumer? What happens if for example a consumer receives a message but does not send back the ack?

book

Article ID: KB0087366

calendar_today

Updated On:

Products Versions
TIBCO Enterprise Message Service -
Not Applicable -

Description

Resolution:
Only one consumer can ever consume each message that is placed on the queue, regardless of whether the queue is exclusive or not. Each message consumer receives a message from the queue and acknowledges receipt of the message. The message is taken off the queue so that no other consumer can receive it.

If the consumer received the message and doesn't acknowledge it, the message won't be consumed by any other EMS consumer, since the message is already delivered. The message will be kept in EMS as long as either it is ack'ed or it's expired.

If you run a tibemsadmin command "show queue &ltqueue name>, it will show the “pending messages” (yet to be delivered to queue consumer(s)) and “delivered messages” (delivered to queue consumer(s) but yet to be ack'ed). If you close any connection which had some “delivered messages”, they will show up in pending messages”.

An unacknowledged message is not resent to the application unless the connection is closed and recreated or if the application calls the session.recover() method.

You need to call session.recover() to ensure message redelivery.

=====================
Session.Recover

Purpose

Recover from undetermined state during message processing.

Remarks

Exceptions during message processing can sometimes leave a program in an ambiguous state. For example, some messages might be partially processed. This method lets a program return to an unambiguous state—the point within the message stream when the program last acknowledged the receipt of inbound messages. Programs can then review the messages delivered since that point (they are marked as redelivered), and resolve ambiguities about message processing.

Programs can also use this method to resolve similar ambiguities after a Connection stops delivering messages, and then starts again.

Operation

This method requests that the server do this sequence of actions:

1. Stop message delivery within the session.

2. Mark as redelivered, any messages that the server has attempted to deliver to the session, but for which it has not received acknowledgement (that is, messages for which processing state is ambiguous).

According to the JMS specification, the server need not redeliver messages in the same order as it first delivered them.

3. Restart message delivery (including messages marked as redelivered in step 2).

Issue/Introduction

Is a message on a queue will only be received by one and only one consumer? What happens if for example a consumer receives a message but does not send back the ack?