Hi,

thanks for answer.
the idea was to use a stream resequencer. In main case messages will be in
right order but sometimes i could have an inversion so with stream
resequencer i will not block these messages.

But i would resequence n different streams as I have no logic order between
A and B and ...

So i would define n stream resequencers [to avoid blocking resequencing of
all stream if one has a gap].

But i don't see if the resequencer is adapted for this particular case.

I could perhaps implement a complex comparator but i don't think being able
to handle n independent streams correctly.

Regards
Hervé

On Wed, Feb 29, 2012 at 11:23 AM, Claus Ibsen <[email protected]> wrote:

> Hi
>
> The resequencer EIP works in 2 modes
> - a) batch
> - b) streaming
>
> Ad a)
> uses a java.util.Comparator to compare to know in which order the
> messages should be.
>
> You can configure such a comparator using something a like
> org.apache.camel.util.ExpressionComparator, which shows you how
> to grab the [A,1] from the message, and then you can do custom java
> code how to compare that. So you can code that [A,1] comes before
> [B,1] etc.
>
> Then you ought to be able to resequence in a mix with [A,1] and [B,1] etc.
>
> The batch mode will emit messages in batches after either a timeout,
> or a certain size has been hit.
>
> Ad b)
> The streaming mode runs in a continues stream, but it requires that
> there is *no* gaps. And by default it only offers a Long based
> comparator.
> You will have to implement your custom comparator which is a:
> org.apache.camel.processor.resequencer.ExpressionResultComparator
>
> And then you need to implement logic to tell which is the prev / next
> exepected message, so the resequencer knows if it got the messages,
> so there is no gaps, and then can emit the messages.
>
>
>
> Mind that the resequencer is purely memory based, it does not offer a
> persistent store, and cannot remember its state. So if you restart or
> server crashes, the messages will be lost.
>
>
>
>
>
> On Wed, Feb 29, 2012 at 9:45 AM, Hervé BARRAULT
> <[email protected]> wrote:
> > Hi,
> >
> > I would order messages in a route
> > I think the resequencer is the right EIP for this but i have some
> > difficulties to see how to apply it in my case.
> >
> > Classical Behavior :
> > input : M[1] M[3] M[2] M[4] , the output will be M[1] M[2] M[3] M[4].
> >
> > In my case i will have the following entry :
> >
> > M[A,1] M[B,1] M[B,2] M[A,4] M[A,5] M[B,4] M[A,3] M[B,3] M[A,2], M[B,5]
> >
> > I would have at the end :
> > M[A,1] M[A,2] M[A,3] M[A,4] M[A,5]
> > M[B,1] M[B,2] M[B,3] M[B,4] M[B,5]
> >
> > We can define one route which separate "A" and "B" messages [basic
> message
> > router].
> >
> > Then two routes (one for "A", one for "B" which do the resequencing
> [basic
> > resequencer] ).
> >
> > If A and B are defined before runtime it's simple.
> > If A and B are not fixed but is a dynamic list, i can't see how to
> > implement this.
> >
> > Is there a way to have this behavior ?
> >
> > Thanks for answers
> >
> > Regards
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: [email protected]
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>

Reply via email to