The broker will dispatch messages to consumers in batches before client's ack, 
then the client will dispatch each message to consumer who is interesting in.
Messages that process unsuccessfully, says messageListener throws 
RuntimeException, will be redispatched to messageLisener by client if not out 
of the max redelivery numbers or client will tell broker the message is a 
poison message and will be deliveyed to DLQ.
When the consumer is closed the broker will redispatch its unacked messages to 
other active consumers.
Hope this will be helpful to you.




At 2011-11-21 22:13:30,Eugene <eugen.ra...@gmail.com> wrote:
>Hey,
>
>Small question here : suppose I have two Consumers (DMLC in Spring - started
>in two different application contexts - two Java VMs), both "listen" to the
>same Queue.
>
>Now I want to keep the DMLC Container started, but at the same time I want
>to be able to disable one of them. And when I say disable I mean not receive
>messages at all in the Queue - so stop() from DMLC will not work. Also
>shutdown will not work either because it will shutdown the DMLC and the idea
>is that the process should be manageable from JMX - so stopping it is not
>really an option.
>
>My idea was this - which actually works:
>
>Extend the DMLC Container and add a flag : "disableMessageConsuming" - true
>or false:
>
>public class CustomDefaultMessageListenerContainer extends
>DefaultMessageListenerContainer {
>
>    private boolean disableMessageConsuming;
>
>    public boolean isDisableMessageConsuming() {
>        return disableMessageConsuming;
>    }
>
>    public void setDisableMessageConsuming(boolean disableMessageConsuming)
>{
>        this.disableMessageConsuming = disableMessageConsuming;
>       
>((MyMessageListener)super.getMessageListener()).setDisableMessageConsuming(disableMessageConsuming);
>    }
>}
>
>Of course the same variable is present in MyMessageListener, which is just a
>class that implements MessageListener - nothing fancy.
>
>Inside MyMessageListener I just check the flag and if it's set to true and
>because of the ACKNOWLEDGMENT the original message is already gone from the
>Queue, so I recreate another one with the same MsgID and payload.
>
>But this looks way too hacky to me - and probably wrong.
>
>What I wanted to do is check the flag and throw and error, so that the
>message get rolled back to the Queue. This, again, happens, BUT it seems
>that ActiveMQ somehow registers it's Consumers to a message and thus this
>already rolled back message can not really be taken by some other consumer.
>
>Is there a way to unregister a message from a particular consumer?
>
>Thx,
>Eugene. 
>
>--
>View this message in context: 
>http://activemq.2283324.n4.nabble.com/ActiveMQ-Dispatcher-Policy-tp4091599p4091599.html
>Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to