You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by nbertram <ni...@gmail.com> on 2014/10/16 04:04:57 UTC

can camel throttle messages based a dynamic message key?

I have a route that is invoked to get a status of an object "foo". The
instance of foo is identified by a key. 

Concurrently at any given time I may receive following requests on the camel
route:

GET status of foo/@id=A12
GET status of foo/@id=A12
GET status of foo/@id=A12
GET status of foo/@id=A30
GET status of foo/@id=A30
GET status of foo/@id=A10

The id of foo is an infinite collection (could be anything).

I would like to throttle all queries for foo/@id=A12, foo/@id=30 and
foo/@id=A10 separately. So that in the example above, 1 route for foo A12,
A30 and A10 is executed but all other requests for A12 and A30 are
throttled.

The Camel Throttle does not seem to support something like this and the only
other thought I had is to use JMS topic. Anyone ever came across a use case
like this before and if so how did you solve it in Camel?

Many thanks,
Niels



--
View this message in context: http://camel.465427.n5.nabble.com/can-camel-throttle-messages-based-a-dynamic-message-key-tp5757611.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: can camel throttle messages based a dynamic message key?

Posted by Henryk Konsek <he...@gmail.com>.
Hi Niels,

> I would like to throttle all queries for foo/@id=A12, foo/@id=30 and
> foo/@id=A10 separately.

What about the content-base routing followed by the different
throttler definition for each choice path?

from("direct:a")
  .choice()
    .when(...)
       .throttle(3).to("direct:b")
     .when(...)
       .throttle(30).to("direct:c")
     .otherwise()
       .to("direct:noThrottle");

Cheers.

-- 
Henryk Konsek
http://henryk-konsek.blogspot.com

Re: can camel throttle messages based a dynamic message key?

Posted by boday <be...@initekconsulting.com>.
Niels, I think what you are looking for is not throttling, but single
threading groups of related messages, correct?  If so, then ActiveMQ message
groups is designed for exactly that and is trivial to implement...

Just route your messages through a JMS queue and set the JMSXGroupId header
set to your "id"  value and AMQ handles the rest...you can also use a
throttler to manage throughput per unit of time if needed...

see these pages for details:

http://activemq.apache.org/message-groups.html

http://camel.apache.org/parallel-processing-and-ordering.html


nbertram wrote
> I have a route that is invoked to get a status of an object "foo". The
> instance of foo is identified by a key. 
> 
> Concurrently at any given time I may receive following requests on the
> camel route:
> 
> GET status of foo/@id=A12
> GET status of foo/@id=A12
> GET status of foo/@id=A12
> GET status of foo/@id=A30
> GET status of foo/@id=A30
> GET status of foo/@id=A10
> 
> The id of foo is an infinite collection (could be anything).
> 
> I would like to throttle all queries for foo/@id=A12, foo/@id=30 and
> foo/@id=A10 separately. So that in the example above, 1 route for foo A12,
> A30 and A10 is executed but all other requests for A12 and A30 are
> throttled.
> 
> The Camel Throttle does not seem to support something like this and the
> only other thought I had is to use JMS topic. Anyone ever came across a
> use case like this before and if so how did you solve it in Camel?
> 
> Many thanks,
> Niels





-----
Ben O'Day
IT Consultant -http://consulting-notes.com

--
View this message in context: http://camel.465427.n5.nabble.com/can-camel-throttle-messages-based-a-dynamic-message-key-tp5757611p5758148.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: can camel throttle messages based a dynamic message key?

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

No the throttler does not support different groups of messages to
throttle differently.



On Thu, Oct 16, 2014 at 4:04 AM, nbertram <ni...@gmail.com> wrote:
> I have a route that is invoked to get a status of an object "foo". The
> instance of foo is identified by a key.
>
> Concurrently at any given time I may receive following requests on the camel
> route:
>
> GET status of foo/@id=A12
> GET status of foo/@id=A12
> GET status of foo/@id=A12
> GET status of foo/@id=A30
> GET status of foo/@id=A30
> GET status of foo/@id=A10
>
> The id of foo is an infinite collection (could be anything).
>
> I would like to throttle all queries for foo/@id=A12, foo/@id=30 and
> foo/@id=A10 separately. So that in the example above, 1 route for foo A12,
> A30 and A10 is executed but all other requests for A12 and A30 are
> throttled.
>
> The Camel Throttle does not seem to support something like this and the only
> other thought I had is to use JMS topic. Anyone ever came across a use case
> like this before and if so how did you solve it in Camel?
>
> Many thanks,
> Niels
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/can-camel-throttle-messages-based-a-dynamic-message-key-tp5757611.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/