You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Vince Iglehart <vi...@kniferiver.com> on 2016/10/21 18:37:01 UTC

SEDA with Aggregation

Hello,
I have some questions on how the SEDA component operates. I am using Camel
2.17.3 in a non clustered environment. 

I have a scenario where I need to 
1. Accept multiple incoming messages using a webservice
2. Aggregate messages using the $body of the message
3. After a lapse of 3 seconds, call RouteB in the same Camel context.
4. Allow RouteB to execute only when there is no message currently being
processed by RouteB. If there are new messages that come in, they must wait
until the current message is processed by RouteB. 

Here is what I have so far:

from("cxf://example.com/incoming").aggregate(simple("${body}"), new
BodyInAggregatingStrategy()).completionTimeout(3000).to("seda:routeB");

from("seda:routeB").to(...)

My understanding is that SEDA will block all incoming messages to RouteB
until the current message has been completed.  Am I correct? Will this
design guarantee that only 1 "instance" of routeB will be running at a time?

 



--
View this message in context: http://camel.465427.n5.nabble.com/SEDA-with-Aggregation-tp5789103.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: SEDA with Aggregation

Posted by Vince Iglehart <vi...@kniferiver.com>.
That is helpful.  

With the completionTimeout() I would like to group messages coming in
through the webservice so that RouteB is not called multiple times.  For
example if there are 500 messages with the same payload coming in through
the webservice, I would like to aggregate all of them into 1 message so that
RouteB is called once.

With the seda implementation, I was attempting to make sure that only 1
instance of RouteB was running at one time.  I think that changing
seda:RouteB to direct:RouteB would accomplish what I need to do.  I wasn't
really clear on how the threading model worked. If it ensures sequential
calls to RouteB, then it will accomplish what I need.  

Regards






--
View this message in context: http://camel.465427.n5.nabble.com/SEDA-with-Aggregation-tp5789103p5789186.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: SEDA with Aggregation

Posted by Brad Johnson <br...@mediadriver.com>.
SEDA will queue messages. So you are basically taking messages off one
queue and dropping them on to another as fast as possible.

I'm pretty sure that isn't the behavior you are after. It is more for
queuing and asynchronous operations.

Try changing route B to direct which is request response.

Since you aren't specifying the number of threads, I believe the number
defaults to one.

I think what may be the confusion is the term blocking queue. That
indicates that the consumer blocks if there aren't any objects to be pulled
from the queue. It doesn't indicate that downstream operations execute
sequentially.

Also, I'd have to check but completion time out means it will time out if
route B doesn't complete in that time. You likely don't need a time out at
all if route B is a direct invocation since no further items will be
removed from the queue until B completes.

On Oct 21, 2016 1:37 PM, "Vince Iglehart" <vi...@kniferiver.com>
wrote:

> Hello,
> I have some questions on how the SEDA component operates. I am using Camel
> 2.17.3 in a non clustered environment.
>
> I have a scenario where I need to
> 1. Accept multiple incoming messages using a webservice
> 2. Aggregate messages using the $body of the message
> 3. After a lapse of 3 seconds, call RouteB in the same Camel context.
> 4. Allow RouteB to execute only when there is no message currently being
> processed by RouteB. If there are new messages that come in, they must wait
> until the current message is processed by RouteB.
>
> Here is what I have so far:
>
> from("cxf://example.com/incoming").aggregate(simple("${body}"), new
> BodyInAggregatingStrategy()).completionTimeout(3000).to("seda:routeB");
>
> from("seda:routeB").to(...)
>
> My understanding is that SEDA will block all incoming messages to RouteB
> until the current message has been completed.  Am I correct? Will this
> design guarantee that only 1 "instance" of routeB will be running at a
> time?
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.
> com/SEDA-with-Aggregation-tp5789103.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>