You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by John Landahl <jo...@landahl.org> on 2010/03/04 20:59:39 UTC

Polling Consumer question

Hi all, a quick question about writing a polling consumer. Is it
possible to write a polling consumer with the Java DSL which polls a,
queue periodically? Ideally I'd like to have the "delay" and
"initialDelay" parameters of the File component, something like this:

    from("activemq:deferred?initialDelay=10000?delay=14400000").to("activemq:main")

The logic attached to the "main" queue sometimes finds items that need
to be deferred for a few hours. Those messages are routed to the
"deferred" queue, and after a few hours they need to go back into the
"main" queue to see if they can be processed.

I've looked at the Timer and Quartz components, but I don't see how I
could use them without writing a separate bean, something like:

    from("timer://deferredTimer?delay=10000?period=14400000").to("bean:deferredConsumer").to("activemq:main")

I was hoping for something simpler than this, since the
deferredConsumer bean would be doing the same work as
.from("activemq:deferred"), but consuming messages periodically rather
than immediately.

I've read the page on the Polling Consumer pattern, but the examples
all require dropping down to Java. I'm willing to do that, of course,
but thought I'd ask first to see if there's a way to do it at the
routing DSL level.

thanks,
John

Re: Polling Consumer question

Posted by Norman Maurer <no...@googlemail.com>.
Let me know how it worked out for you...

Bye,
Norman

2010/3/5 John Landahl <jo...@landahl.org>:
> On Fri, Mar 5, 2010 at 12:37 PM, Norman Maurer
> <no...@googlemail.com> wrote:
>> just read my last comments ..
>>
>> http://old.nabble.com/Activemq-component-und-Delayer-ts27784918.html
>>
>> I think the selector is the way to go.
>
> I did, but I didn't see how selectors were any different from a Camel
> filter (the unintended cigarette puns must fly fast and furious in
> here!). Reading more closely now, I see that selectors work at the
> broker level, so it sounds like it should work like the cron feature
> coming in ActiveMQ 5.4 (i.e. the message won't become visible to
> consumers until the selector returns true). That sounds good, if it's
> possible to get the current time in a selector. Will try this later
> today. Thanks again, Norman.
>
> - John
>

Re: Polling Consumer question

Posted by John Landahl <jo...@landahl.org>.
On Fri, Mar 5, 2010 at 12:37 PM, Norman Maurer
<no...@googlemail.com> wrote:
> just read my last comments ..
>
> http://old.nabble.com/Activemq-component-und-Delayer-ts27784918.html
>
> I think the selector is the way to go.

I did, but I didn't see how selectors were any different from a Camel
filter (the unintended cigarette puns must fly fast and furious in
here!). Reading more closely now, I see that selectors work at the
broker level, so it sounds like it should work like the cron feature
coming in ActiveMQ 5.4 (i.e. the message won't become visible to
consumers until the selector returns true). That sounds good, if it's
possible to get the current time in a selector. Will try this later
today. Thanks again, Norman.

- John

Re: Polling Consumer question

Posted by Norman Maurer <no...@googlemail.com>.
Hi John,

just read my last comments ..

http://old.nabble.com/Activemq-component-und-Delayer-ts27784918.html

I think the selector is the way to go.

Bye,
Norman

2010/3/5 John Landahl <jo...@landahl.org>:
> On Thu, Mar 4, 2010 at 9:19 PM, Claus Ibsen <cl...@gmail.com> wrote:
>> John says at this thread
>> http://old.nabble.com/Activemq-component-und-Delayer-ts27784918.html
>>
>> That this questions is answered.
>
> But as the other person in that thread said, now we just have to wait
> for ActiveMQ 5.4.
>
> Reading through that thread gave me an idea that might work, though.
> I'm going to try a simple .filter() in the DSL, testing against a time
> value in a header that says when it's ok to re-process the message. If
> this doesn't work, I'll just write a bean as mentioned in the Polling
> Consumer page.
>
> - John
>

Re: Polling Consumer question

Posted by John Landahl <jo...@landahl.org>.
On Thu, Mar 4, 2010 at 9:19 PM, Claus Ibsen <cl...@gmail.com> wrote:
> John says at this thread
> http://old.nabble.com/Activemq-component-und-Delayer-ts27784918.html
>
> That this questions is answered.

But as the other person in that thread said, now we just have to wait
for ActiveMQ 5.4.

Reading through that thread gave me an idea that might work, though.
I'm going to try a simple .filter() in the DSL, testing against a time
value in a header that says when it's ok to re-process the message. If
this doesn't work, I'll just write a bean as mentioned in the Polling
Consumer page.

- John

Re: Polling Consumer question

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

John says at this thread
http://old.nabble.com/Activemq-component-und-Delayer-ts27784918.html

That this questions is answered.

On Thu, Mar 4, 2010 at 8:59 PM, John Landahl <jo...@landahl.org> wrote:
> Hi all, a quick question about writing a polling consumer. Is it
> possible to write a polling consumer with the Java DSL which polls a,
> queue periodically? Ideally I'd like to have the "delay" and
> "initialDelay" parameters of the File component, something like this:
>
>    from("activemq:deferred?initialDelay=10000?delay=14400000").to("activemq:main")
>
> The logic attached to the "main" queue sometimes finds items that need
> to be deferred for a few hours. Those messages are routed to the
> "deferred" queue, and after a few hours they need to go back into the
> "main" queue to see if they can be processed.
>
> I've looked at the Timer and Quartz components, but I don't see how I
> could use them without writing a separate bean, something like:
>
>    from("timer://deferredTimer?delay=10000?period=14400000").to("bean:deferredConsumer").to("activemq:main")
>
> I was hoping for something simpler than this, since the
> deferredConsumer bean would be doing the same work as
> .from("activemq:deferred"), but consuming messages periodically rather
> than immediately.
>
> I've read the page on the Polling Consumer pattern, but the examples
> all require dropping down to Java. I'm willing to do that, of course,
> but thought I'd ask first to see if there's a way to do it at the
> routing DSL level.
>
> thanks,
> John
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus