You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by anupamsen <an...@yahoo.com> on 2012/09/25 09:38:08 UTC
How To implement a periodically polled queue.
Hi,
I have the following requirement -
1) If a message is received on the save entity route and the authentication
server is not available, then queue up the request in the
*periodicallyPolledInputQueue*.
2) The *periodicallyPolledInputQueue* thus may have n number of messages.
3) Every 30 minutes fetch all the messages in the
*periodicallyPolledInputQueue* and queue them back up to the *saveEntity*
queue using a producer template in the processor
*periodicallyPolledInputHandler*
<route id="saveEntityRoute"
errorHandlerRef="PeriodicallyPolledInputQueue-ErrorHandler" trace="true">
<from uri="jms:queue:JMS-Server/saveEntity?concurrentConsumers=10" />
<camel:transacted ref="PROPAGATION_REQUIRED"/>
<process ref="authenticator" />
<camel:choice>
<camel:when>
<camel:simple>${header.SESSION_ID} == null and
${header.SERVER_AVAILABLE_TOKEN} == 'NO'</camel:simple>
<to
uri="jms:queue:JMS-Server/periodicallyPolledInputQueue?disableReplyTo=true"
/>
</camel:when>
<camel:when>
<camel:simple>${header.SESSION_ID} == null and
${header.SERVER_AVAILABLE_TOKEN} != 'NO'</camel:simple>
<camel:stop></camel:stop>
</camel:when>
<camel:otherwise>
<to uri="xslt:xsl/Transform.xsl" />
<convertBodyTo type="java.lang.String"/>
<delay><constant>300</constant></delay>
<to uri="bean:entityData?method=saveEntity(${body},
${header.SESSION_ID}, ${header.ACK_ID})"/>
<to uri="jms:queue:JMS-Server/saveEntityAck?disableReplyTo=true" />
</camel:otherwise>
</camel:choice>
</route>
<route id="periodicallyPolledInputQueueHandlerRoute">
<from
uri="quartz://periodicallyPolledInputQueueHandler?cron=0+0/30+*+*+*+?"/>
<camel:transacted ref="PROPAGATION_REQUIRED"/>
<pollEnrich
uri="jms:queue:JMS-Server/periodicallyPolledInputQueue?disableReplyTo=true"/>
<process ref="periodicallyPolledInputHandler" />
</route>
The goal is to setup a fail-safe system that would ensure that the
integration layer is available even if the authentication system is down and
we can reprocess the messages.
The questions now -
1) Is this approach correct.
2) I tested this works but strangely just picks a single message only from
the input queue "periodicallyPolledInputQueue" even if tehre are n messages
lying. Is this teh behaviour of quarts+pollenrich on JMS?
Thanks.
--
View this message in context: http://camel.465427.n5.nabble.com/How-To-implement-a-periodically-polled-queue-tp5719920.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How To implement a periodically polled queue.
Posted by anupamsen <an...@yahoo.com>.
Thanks Claus, for the reply.
I thought so, but then for the time-being my problem is solved and maybe in
future we can see some new component in Camel for this as I believe JMS
(with peristent store) is a reasonable fallback for retrying in case any of
the services being unreachable/down.
Cheers,
Anupam
--
View this message in context: http://camel.465427.n5.nabble.com/How-To-implement-a-periodically-polled-queue-tp5719920p5720299.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How To implement a periodically polled queue.
Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Sep 25, 2012 at 9:36 PM, anupamsen <an...@yahoo.com> wrote:
> For the time being, I am using a consumer template to fetch n number of
> messages in the *periodicallyPolledInputHandler* processor triggered from
> the quartz and pushing it to the originating queue using a producer
> template.
>
Yeah this is a doable approach.
> Is there a better way of doing this?
>
Not really as the control structure in the DSL would not support this easily.
eg its kinda like a while loop while there is more messages to poll.
while(more) {
message = poll message
do stuff
}
The loop DSL does not support a "while" structure.
And pollEnrich is single message only.
We had looked into making pollEnrich support multiple message (batch
like) but that causes other problems.
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-To-implement-a-periodically-polled-queue-tp5719920p5719975.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Re: How To implement a periodically polled queue.
Posted by anupamsen <an...@yahoo.com>.
For the time being, I am using a consumer template to fetch n number of
messages in the *periodicallyPolledInputHandler* processor triggered from
the quartz and pushing it to the originating queue using a producer
template.
Is there a better way of doing this?
--
View this message in context: http://camel.465427.n5.nabble.com/How-To-implement-a-periodically-polled-queue-tp5719920p5719975.html
Sent from the Camel - Users mailing list archive at Nabble.com.