I want to take an exchange and send it along a series of processors until
one of them uses it and sets the next route to "direct:done"; I'd rather
not use content based routing because I want the work it takes decide if
the exchange is for a particular processor reused inside of the processor
and the source code for this living within the processor.

Perhaps using the routing slip EIP is the way to go with this?   Any
suggestions would be great appreciated please.   Thanks! --Matt Payne

// Use hopCount to index this...
String preDeterminedRoute[] = { "direct:redWorker","direct:greenWorker" };
Processor blueWorker = new BlueWorkProcessor(preDeterminedRoute);
Processor redWorker = new RedWorkProcessor(preDeterminedRoute);
Processor greenWorker = new GreenWorkProcessor(preDeterminedRoute);

from("direct:blueWorker").process(blueWorker).routingSlip(header("nextRoute"),
"#");
from("direct:redWorker").process(redWorker).routingSlip(header("nextRoute"),
"#");
from("direct:greenWorker").process(greenWorker).routingSlip(header("nextRoute"),
"#");
from("direct:done").to("mock:done");

I have a working CamelTestSupport class online[1]

[1]
https://github.com/payne/CamelSqlDemo/blob/master/RoutingSlipPractice/src/test/java/org/mattpayne/camel/RoutingSlipTest.java#L26


On Tue, Mar 25, 2014 at 3:32 PM, Matt Payne <pa...@mattpayne.org> wrote:

>
> I'm picking up an object to work from a directory and instead of using
> content based routing (because the predicates are complex), I'm thinking of
> doing something like this:
>
> from("direct:workEventQueue")
>
> .process(blueWorker).choice().when(header("done").isNotNull()).to("direct:done")
>
> .process(redWorker).choice().when(header("done").isNotNull()).to("direct:done")
> .process(greenWorker).choice().when(header("done").isNotNull()).to("direct:done");
>
>
> where the processor sets the header if work has been completed and the
> exchange does not need to be routed through the other processors.
>
> My question are: Is this a reasonable way to perform the work?   Does this
> technique have an EIP pattern name please?
>
> Thanks! --Matt Payne
>
>
>
>


-- 
--Matt Payne

Reply via email to