activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpcook01 <jonathan.c...@erars.plus.com>
Subject Re: Pause/Resume MessageListener using DefaultMessageListenerContainer
Date Mon, 27 Aug 2012 17:28:43 GMT
Thanks, the only problem with the onPause flag option is that when I pause my message listener
I want messages to stay on the broker. By the time the code runs in the message listener the
message will have been downloaded from the broker particularly as this method is asynchronous.

Will have a look at starting and stopping the message container.

Thanks
Jon


----- Reply message -----
From: "Gaurav Sharma [via ActiveMQ]" <ml-node+s2283324n4655621h81@n4.nabble.com>
To: "jpcook01" <jonathan.cook@erars.plus.com>
Subject: Pause/Resume MessageListener using DefaultMessageListenerContainer
Date: Mon, Aug 27, 2012 18:00
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 <[hidden email]>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:
> http://activemq.2283324.n4.nabble.com/Pause-Resume-MessageListener-using-DefaultMessageListenerContainer-tp4655590.html>
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>









If you reply to this email, your message will be added to the discussion below:
http://activemq.2283324.n4.nabble.com/Pause-Resume-MessageListener-using-DefaultMessageListenerContainer-tp4655590p4655621.html



To unsubscribe from Pause/Resume MessageListener using DefaultMessageListenerContainer, click
here.
NAML



--
View this message in context: http://activemq.2283324.n4.nabble.com/Pause-Resume-MessageListener-using-DefaultMessageListenerContainer-tp4655590p4655623.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message