activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gaurav Sharma <>
Subject Re: Pause/Resume MessageListener using DefaultMessageListenerContainer
Date Mon, 27 Aug 2012 16:59:31 GMT
Hmm, actually, if you do setMessageListener(null) on
the DefaultMessageListenerContainer, it will throw an
IllegalArgumentException in checkMessageListener(), so, that shouldn't work.

The stop(), start(), isRunning() methods do seem like a good option to
pause the listener via spring. The other way would be to use a table in db
or just a (visible to the listener thread) flag like isPaused and then in
the onMessage() of your listener, the thread sleep-spins until this
isPaused is set to false. The isPaused will always be read-only for the
listener thread but you can toggle isPaused externally based on your
control flow.

On Mon, Aug 27, 2012 at 3:46 AM, jpcook01 <>wrote:

> Hi,
> I am using a Asynchronous MessageListener with onMessage within a
> DefaultMessageListenerContainer. My service is then deployed into tomcat.
> I would like to know if there is a recommended way for
> activating/deactivating my messagelistener programatically? It seems like
> quite a reasonable or common use case but there doesn't appear to be any
> obvious recommended approach for achieving this. The approach seems to be
> to
> get the DefaultMessageListenerContainer from the application context and
> calling the stop() method to basically stop the connection and then start
> again. Or I've read just calling setMessageListener(null) might achieve the
> same.
> I'm using a
>     <listener>
> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
>     </listener>
> So the entry point into my application is my MessageListener and wiring in
> the following logic to my MessageListener onMessage method seems a bit
> messy
> and I'm not sure if there will be some strange side affect from stopping my
> connection from within an async messagelistener.
> I wondered if there was a better way to do this maybe using JMX or JDNI? Or
> is my suggestion the recommended approach. We don't really want to have to
> start and stop the tomcat container every time we want to pause message
> consumption?
> Thanks
> Jon
> --
> View this message in context:
> Sent from the ActiveMQ - User mailing list archive at

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message