You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by developpef <sr...@orange.fr> on 2013/02/27 11:46:43 UTC
Split an empty list
Hello,
Here is what happens :
My route is :
from("direct:inside")
.log(LoggingLevel.INFO, "**** start")
.beanRef(MY_SERVICE, "retrieveDataList")
.log(LoggingLevel.INFO, "**** before split ${body}")
.split(body())
.log(LoggingLevel.INFO, "**** after split ${body}")
And my logs :
|2013-02-27 11:30:58|INFO|route3|**** start|
|2013-02-27 11:30:58|INFO|route3|**** before split []|
That's all! When my bean retrieves an empty list, the SPLIT shortcuts my
whole route and nothing is done after on it... With a not empty list, it
works fine.
I'm using Camel 2.10.2
Did I miss something?
Thanks
-----
http://developpef.blogspot.com
--
View this message in context: http://camel.465427.n5.nabble.com/Split-an-empty-list-tp5728214.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Split an empty list
Posted by developpef <sr...@orange.fr>.
Just a proposal : it might be great to write in the documentation a post
about how to manage the ".end()" instruction : what components need it? how
two not "cross" them and avoid confusions?
Like in :
.loop(3)
.to(...)
.split(...)
.end() --> what END is it?
-----
http://developpef.blogspot.com
--
View this message in context: http://camel.465427.n5.nabble.com/Split-an-empty-list-tp5728214p5728226.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Split an empty list
Posted by developpef <sr...@orange.fr>.
OK, after a test, you're right, it is now working as expected.
Thanks for pointing me this tip!
-----
http://developpef.blogspot.com
--
View this message in context: http://camel.465427.n5.nabble.com/Split-an-empty-list-tp5728214p5728225.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Split an empty list
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Yes its this eip
http://camel.apache.org/composed-message-processor.html
The Camel splitter has a built-in aggregation stragegy which is much
easier to use than split + aggregate.
See the example on the page above, about using ONLY splitter.
On Wed, Feb 27, 2013 at 1:28 PM, developpef <sr...@orange.fr> wrote:
> Well, after my SPLIT I use an aggregation Strategy with completionPredicate
> to Exchange.SPLIT_COMPLETE.
>
> So if I understand, I would rather write :
>
> .split(body(), myAggregationStrategy)
> (... split operations ...)
> .end()
>
> rather than :
>
> .split(body())
> (... split operations ...)
> .aggregate(...)
> .completionPredicate(header(Exchange.SPLIT_COMPLETE).isEqualTo(Boolean.TRUE))
>
> Am I right? And in the first case, will my aggregation strategy complete on
> Exchange.SPLIT_COMPLETE as well?
>
>
>
> -----
> http://developpef.blogspot.com
> --
> View this message in context: http://camel.465427.n5.nabble.com/Split-an-empty-list-tp5728214p5728221.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Re: Split an empty list
Posted by developpef <sr...@orange.fr>.
Well, after my SPLIT I use an aggregation Strategy with completionPredicate
to Exchange.SPLIT_COMPLETE.
So if I understand, I would rather write :
.split(body(), myAggregationStrategy)
(... split operations ...)
.end()
rather than :
.split(body())
(... split operations ...)
.aggregate(...)
.completionPredicate(header(Exchange.SPLIT_COMPLETE).isEqualTo(Boolean.TRUE))
Am I right? And in the first case, will my aggregation strategy complete on
Exchange.SPLIT_COMPLETE as well?
-----
http://developpef.blogspot.com
--
View this message in context: http://camel.465427.n5.nabble.com/Split-an-empty-list-tp5728214p5728221.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Split an empty list
Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Feb 27, 2013 at 11:46 AM, developpef <sr...@orange.fr> wrote:
> Hello,
>
> Here is what happens :
>
> My route is :
>
> from("direct:inside")
> .log(LoggingLevel.INFO, "**** start")
> .beanRef(MY_SERVICE, "retrieveDataList")
> .log(LoggingLevel.INFO, "**** before split ${body}")
> .split(body())
> .log(LoggingLevel.INFO, "**** after split ${body}")
>
> And my logs :
>
> |2013-02-27 11:30:58|INFO|route3|**** start|
> |2013-02-27 11:30:58|INFO|route3|**** before split []|
>
> That's all! When my bean retrieves an empty list, the SPLIT shortcuts my
> whole route and nothing is done after on it... With a not empty list, it
> works fine.
>
> I'm using Camel 2.10.2
>
> Did I miss something?
>
No the splitter only outputs messages if there is data to split. And
if you have an empty list / null body etc. then nothing is output from
the splitter.
If you want to do stuff AFTER the splitter is fully done, then close
the block with end(), eg
form
to
split body
to inside splitter
end()
to outside splitter
> Thanks
>
>
>
> -----
> http://developpef.blogspot.com
> --
> View this message in context: http://camel.465427.n5.nabble.com/Split-an-empty-list-tp5728214.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen