You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by spiderman2 <sh...@bridgewatersystems.com> on 2007/04/26 20:28:40 UTC

If I want to rollback a message

What are my options for the following requirement:

Step 1: A consumer gets a message from a broker's queue (which will likely
use roundrobin).
Step 2: It realizes that it doesn't want this particular message at this
time, so the broker should deliver it to another consumer.

Here are the options I can think of, please tell me if there are more and if
one is better:

1. I use CLIENT_ACKKNOWLEDGE sessions and close the session such that the
Broker can then distribute the message to another consumer.
    Downside: I have to incur the cost of shutting down and restarting the
session.

2. I use SESSION_TRANSACTED sessions and call a rollback with the hopes that
the same consumer doesn't get the message again.

3. I can consume the message from the Broker and produce it back on the
Broker, at the end of its queue.
    Downside: The message goes back on the end of the queue. Not clean.

NOTE: I don't believe I can use Message Selectors because the I need my
filter criteria to be dynamic.

Is there any cleaner way?
If transacted sessions is the answer, will this hurt me in performance?
-- 
View this message in context: http://www.nabble.com/If-I-want-to-rollback-a-message-tf3653356s2354.html#a10206088
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: If I want to rollback a message

Posted by James Strachan <ja...@gmail.com>.
On 4/26/07, spiderman2 <sh...@bridgewatersystems.com> wrote:
>
> What are my options for the following requirement:
>
> Step 1: A consumer gets a message from a broker's queue (which will likely
> use roundrobin).
> Step 2: It realizes that it doesn't want this particular message at this
> time, so the broker should deliver it to another consumer.

Transacted sessions are the only real way to undeliver a message; but
then the JMS client will replay the messsage N times before its really
failed back to the broker (based on the RedeliveryPolicy). You could
just wait until the time is right to be able to consume the message?


Generally speaking, its considered bad form to consume messages then
realise they're not for you and try to un-deliver them. You really
should use selectors to filter out what you need. If for whatever
reason you can't use selectors then you should place the message on a
different queue for 'someone else' to process (so that its then easy
to filter out yourself from getting the message again). i.e. using the
the 'undeliver' approach its very easy for messages to be continuously
delivered to the wrong consumer & cause loads of unnecessary work.

-- 
James
-------
http://macstrac.blogspot.com/