activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eugene <>
Subject ActiveMQ Dispatcher Policy
Date Mon, 21 Nov 2011 14:13:30 GMT

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;

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?


View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message