You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Martin Gilday <ma...@imap.cc> on 2011/01/07 12:20:14 UTC

Consuming messages based on a predicate

Hi,

I am building a Camel route which consumes from a JMS queue, does JSON
to XML conversion and then calls a web service to send requests to a
third party.  This third party only wants to receive the messages during
their opening hours.  This made me immediately think to use the Quartz
component to consume during certain hours.  However their opening hours
change frequently, and we have a database table which stores the current
schedule. There is a nice service with a method isOpen() which can
determine whether they are open currently.  If I take the message off
the queue and then check the predicate it could be looping the messages
around for hours or days at a time until they are open.

Is there a nice way to create a route to do this?

Thanks,
Martin

Re: Consuming messages based on a predicate

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jan 7, 2011 at 1:42 PM, Martin Gilday <ma...@imap.cc> wrote:
> Thanks, Claus.
>
> We are still on Camel 2.3 at the moment with this project.  Are there
> any alternatives?
>

If RoutePolicy SPI is part of Camel 2.3, then its all you need. Just
implement it with that open/close logic and assign it to the route.


> Martin.
>
> ----- Original message -----
> From: "Claus Ibsen" <cl...@gmail.com>
> To: users@camel.apache.org
> Date: Fri, 7 Jan 2011 12:46:48 +0100
> Subject: Re: Consuming messages based on a predicate
>
> On Fri, Jan 7, 2011 at 12:20 PM, Martin Gilday <ma...@imap.cc>
> wrote:
>> Hi,
>>
>> I am building a Camel route which consumes from a JMS queue, does JSON
>> to XML conversion and then calls a web service to send requests to a
>> third party.  This third party only wants to receive the messages during
>> their opening hours.  This made me immediately think to use the Quartz
>> component to consume during certain hours.  However their opening hours
>> change frequently, and we have a database table which stores the current
>> schedule. There is a nice service with a method isOpen() which can
>> determine whether they are open currently.  If I take the message off
>> the queue and then check the predicate it could be looping the messages
>> around for hours or days at a time until they are open.
>>
>> Is there a nice way to create a route to do this?
>>
>
> Something similar to
> http://camel.apache.org/scheduledroutepolicy.html
>
> But instead just implement your own "scheduling" logic. For example
> have a background thread invoke once a minute or something and
> determine if its open. And then suspend/resume the route accordingly.
>
>> Thanks,
>> Martin
>>
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Consuming messages based on a predicate

Posted by Martin Gilday <ma...@imap.cc>.
Thanks, Claus.

We are still on Camel 2.3 at the moment with this project.  Are there
any alternatives?

Martin.

----- Original message -----
From: "Claus Ibsen" <cl...@gmail.com>
To: users@camel.apache.org
Date: Fri, 7 Jan 2011 12:46:48 +0100
Subject: Re: Consuming messages based on a predicate

On Fri, Jan 7, 2011 at 12:20 PM, Martin Gilday <ma...@imap.cc>
wrote:
> Hi,
>
> I am building a Camel route which consumes from a JMS queue, does JSON
> to XML conversion and then calls a web service to send requests to a
> third party.  This third party only wants to receive the messages during
> their opening hours.  This made me immediately think to use the Quartz
> component to consume during certain hours.  However their opening hours
> change frequently, and we have a database table which stores the current
> schedule. There is a nice service with a method isOpen() which can
> determine whether they are open currently.  If I take the message off
> the queue and then check the predicate it could be looping the messages
> around for hours or days at a time until they are open.
>
> Is there a nice way to create a route to do this?
>

Something similar to
http://camel.apache.org/scheduledroutepolicy.html

But instead just implement your own "scheduling" logic. For example
have a background thread invoke once a minute or something and
determine if its open. And then suspend/resume the route accordingly.

> Thanks,
> Martin
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/


Re: Consuming messages based on a predicate

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jan 7, 2011 at 12:20 PM, Martin Gilday <ma...@imap.cc> wrote:
> Hi,
>
> I am building a Camel route which consumes from a JMS queue, does JSON
> to XML conversion and then calls a web service to send requests to a
> third party.  This third party only wants to receive the messages during
> their opening hours.  This made me immediately think to use the Quartz
> component to consume during certain hours.  However their opening hours
> change frequently, and we have a database table which stores the current
> schedule. There is a nice service with a method isOpen() which can
> determine whether they are open currently.  If I take the message off
> the queue and then check the predicate it could be looping the messages
> around for hours or days at a time until they are open.
>
> Is there a nice way to create a route to do this?
>

Something similar to
http://camel.apache.org/scheduledroutepolicy.html

But instead just implement your own "scheduling" logic. For example
have a background thread invoke once a minute or something and
determine if its open. And then suspend/resume the route accordingly.

> Thanks,
> Martin
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/