You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by gilboy <jo...@gmail.com> on 2015/08/26 12:18:38 UTC

Getting JMSConsumer to look for messages every N seconds

Hi 

I have a use case where I want to take messages from a DLQ and place them
back on to main/primary queue which feeds the application. I want to move
the messages every 10 seconds. I have looked at the delayer EIP but I would
prefer take them from the DLQ every 10 seconds rather than taking them as
they become available and storing them in memory. 

Is there any way I can get my JMSConsumer to look for messages every 10
seconds

Thanks
Joe



--
View this message in context: http://camel.465427.n5.nabble.com/Getting-JMSConsumer-to-look-for-messages-every-N-seconds-tp5770986.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Getting JMSConsumer to look for messages every N seconds

Posted by Christian Müller <ch...@gmail.com>.
Or use the timer component to send a message each 10 seconds to a
processor. This processor could use a consumer template to poll the queue
in a loop and send the message to another camel route with a producer
template (using the direct component ).
The consumer template also has a timeout parameter. You can use it to break
out from the loop, if there is no message in the queue.

I think this is an easier - less sophisticated  - solution.

Best,
Christian
Am 27.08.2015 00:59 schrieb "Raul Kripalani" <ra...@evosent.com>:

> Currently I think that we only support fixed schedules. So with the cron
> scheduler you could achieve something like: start/resume the route on every
> minute at 00 and 30 seconds, stop/suspend every minute at 10 and 40 seconds
> time marks.
>
> This would effectively keep your route running for 10 seconds every 30
> seconds.
>
> If you want something more sophisticated, like stopping it once the queue
> is empty, you would need to extend what we offer OOTB with your own logic.
>
> Maybe you want to stop the route when t be consumer has been inactive for 1
> second or 500ms, or when queue size is 0 at the broker (checking via JMX).
>
> Raúl.
> On 26 Aug 2015 23:19, "gilboy" <jo...@gmail.com> wrote:
>
> > Thanks for the feedback. So just to confirm if I have the following route
> > and
> > I want to consume a message every 30 seconds would I inject in to the
> route
> > a RoutePolicy(e.g. SimpleScheduledRoutePolicy) where I specify the
> > routeStartRepeatInterval(30 seconds). I feel like I am missing something.
> > What shuts down the route etc
> >
> > from("jms:endpointDetails")
> >    .routeId("test")
> >    .routePolicy(policy)
> >    .to("mock:success");
> >
> > Thanks
> > Joe
> >
> >
> >
> > --
> > View this message in context:
> >
> http://camel.465427.n5.nabble.com/Getting-JMSConsumer-to-look-for-messages-every-N-seconds-tp5770986p5770997.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
>

Re: Getting JMSConsumer to look for messages every N seconds

Posted by Raul Kripalani <ra...@evosent.com>.
Currently I think that we only support fixed schedules. So with the cron
scheduler you could achieve something like: start/resume the route on every
minute at 00 and 30 seconds, stop/suspend every minute at 10 and 40 seconds
time marks.

This would effectively keep your route running for 10 seconds every 30
seconds.

If you want something more sophisticated, like stopping it once the queue
is empty, you would need to extend what we offer OOTB with your own logic.

Maybe you want to stop the route when t be consumer has been inactive for 1
second or 500ms, or when queue size is 0 at the broker (checking via JMX).

Raúl.
On 26 Aug 2015 23:19, "gilboy" <jo...@gmail.com> wrote:

> Thanks for the feedback. So just to confirm if I have the following route
> and
> I want to consume a message every 30 seconds would I inject in to the route
> a RoutePolicy(e.g. SimpleScheduledRoutePolicy) where I specify the
> routeStartRepeatInterval(30 seconds). I feel like I am missing something.
> What shuts down the route etc
>
> from("jms:endpointDetails")
>    .routeId("test")
>    .routePolicy(policy)
>    .to("mock:success");
>
> Thanks
> Joe
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Getting-JMSConsumer-to-look-for-messages-every-N-seconds-tp5770986p5770997.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Getting JMSConsumer to look for messages every N seconds

Posted by gilboy <jo...@gmail.com>.
Thanks for the feedback. So just to confirm if I have the following route and
I want to consume a message every 30 seconds would I inject in to the route
a RoutePolicy(e.g. SimpleScheduledRoutePolicy) where I specify the
routeStartRepeatInterval(30 seconds). I feel like I am missing something.
What shuts down the route etc

from("jms:endpointDetails")
   .routeId("test")
   .routePolicy(policy)
   .to("mock:success");

Thanks
Joe



--
View this message in context: http://camel.465427.n5.nabble.com/Getting-JMSConsumer-to-look-for-messages-every-N-seconds-tp5770986p5770997.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Getting JMSConsumer to look for messages every N seconds

Posted by Raul Kripalani <ra...@evosent.com>.
Yes, you can use a Scheduled Route Policy [1] to schedule the activation
and deactivation of your route. That, with a JMS consumer, should do the
trick.

[1] https://camel.apache.org/scheduledroutepolicy.html

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Wed, Aug 26, 2015 at 11:18 AM, gilboy <jo...@gmail.com> wrote:

> Hi
>
> I have a use case where I want to take messages from a DLQ and place them
> back on to main/primary queue which feeds the application. I want to move
> the messages every 10 seconds. I have looked at the delayer EIP but I would
> prefer take them from the DLQ every 10 seconds rather than taking them as
> they become available and storing them in memory.
>
> Is there any way I can get my JMSConsumer to look for messages every 10
> seconds
>
> Thanks
> Joe
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Getting-JMSConsumer-to-look-for-messages-every-N-seconds-tp5770986.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>