E.S.
E.S.

Reputation: 2841

How to reject a message

I am implementing a client/workers system using ActiveMQ and I would like to implement a manual Message Acknowledgement and Message Rejection.

Why reject messages? If a worker has too many tasks coming at it, I want that worker to tell the broker to re-queue the original message.

I know there are ways to auto acknowledge or implement transactions, but I'd rather have something like this:

  1. Messages need to be acknowledged within 5 seconds
  2. If they are not acknowledged, the broker will send the message to a different worker
  3. Works can manually reject a message at any time

How can I implement this (without just resending the message to the broker manually)

UPDATE:

To rephrase the question slightly: How can I ensure unacknowledged messages are re-added back to the queue (and re-delivery can go back to the same consumer that previously did not acknowledge it even -- say that consumer went offline and then came back)

Upvotes: 3

Views: 3297

Answers (1)

Mayoares
Mayoares

Reputation: 1284

ActiveMQ web page about queues:

If a consumer receives a message and does not acknowledge it before closing then the message will be redelivered to another consumer.

That's what you want, right? So you have to turn off the AUTO_ACKNOWLEDGEMENT mode and use another mode: CLIENT_ACKNOWLEDGE or probably more selective the INDIVIDUAL_ACKNOWLEDGE.

Rejecting a message is not (yet) possible, see ActiveMQ-Docu:

There is no JMS 'unacknowledge'.

Upvotes: 3

Related Questions