camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roman Kalukiewicz" <roman.kalukiew...@gmail.com>
Subject Re: Aggregation with idle timeouts
Date Sun, 06 Apr 2008 10:14:07 GMT
2008/4/3, fuchsmi <michael.fuchs@fatwire.com>:
>  Anyway, one feature we need is to aggregate based on a groupid with an
>  timeout. To give an simple example, every hit of a visitor of an website is
>  one message, its sessionid is the groupid. so we aggragate based on the
>  users sessionid. now we want to finish the aggragation after the user is 30
>  minutes idle.
>
>
>  Is it possible to implement that based on the Aggragator pattern? Is there
>  an existing implementation of a functionallity like this?

I'm afraid that such functionality is not supported directly, and that
we don't have an example.

The solution I could think about is little tricky, but should work
(anyway I think we should have this functionality 'directly' ;).

from("direct:start").to("direct:aggregator", "seda:timer");
from("direct:aggregator").aggregator(header("correlation"), new
MyStrategy()).completedPredicate(header("completed").isNotNull()).to("direct:end");
from("seda:timer").delayer(30000).setBody(constant(MARKER)).to("direct:aggregator");

Then your MyStrategy class has to:
1) recognize MARKER body as the one that signals timeout
2) store in result exchange the last message Id received
3) if MARKER body received and the last messageID aggregated is the
one received with MARKER body, then set "completed" header that will
be discovered by completedPredicate.

Solution is not pretty and we should have something like
iddleTimeout() parameter to aggregator, but should work (I think).

It is not tested at all, and could even not compile directly ;) but
should be OK.

Romek

Mime
View raw message