So, say we have the follwing (simplified) route setup:
RouteDefination routeDef = from("seda:somewhereIrrelevant")
.process(someProcessor1); // normal message.
if ( typeOfRoute.equals("requiresList"){
routeDef.process(addsAListToBody); // creates list out of normal message.
}
routeDef.split().body()
.process(oneMessageAtATime) // this is regardless of whether it was originally a part of a list.
.end();
The thing is, I can see that this works with or without "addsAListToBody"
Processor. It we pass a normal object of type Foo
it passes on the exchange to "oneMessageAtATime" Processor. If the route contains "addsAListToBody"
Processor that returns a List<Foo>
then it splits the list into Foo
elements that get processed one by one.
The thing is, this seems like a very simple thing that solves what I want to do but for some reason it feels like it's wrong.
Is this "conditional" useage of splitter correct? Or am I doing something wrong here?
question from:
https://stackoverflow.com/questions/65626386/is-it-safe-to-use-split-body-when-the-exchange-may-or-may-not-contain-an-ite 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…