Returning a Message to the Queue
A subscriber can also explicitly release a message back to the queue.
AMPS returns the message to the queue, and redelivers the message just
as though the lease had expired. To do this, the subscriber sends a
sow_delete
command with the bookmark of the message to release and
the cancel
option.
When using automatic acknowledgments and the asynchronous API, AMPS will cancel a message if an exception is thrown from the message handler.
To return a message to the queue, you can build a sow_delete
acknowledgment using the Command
class, or pass an option to the
ack()
method on the message.
Option | Result |
---|---|
cancel | Returns the message to the queue. |
expire | Immediately expire the message from the queue. |
For example, to return a message to a queue, call ack()
on the message
and pass the cancel
option.
message.ack("cancel");