Take a look at the scatter - gather EIP.and Splittier That should solve your problem. If you are using Loop, you are probably already doing something wrong. Scatter-gather with seda or jms is a better solution. The number of legit use cases for loops are small. Remember you can create a custom splitter that will copy exchanges any number of times.
*Robert Simmons Jr. MSc. - Lead Java Architect @ EA* *Author of: Hardcore Java (2003) and Maintainable Java (2012)* *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39 <http://www.linkedin.com/pub/robert-simmons/40/852/a39>* On Thu, Jun 5, 2014 at 5:00 AM, jamalissimo <[email protected]> wrote: > Hello guys, > > I am solving a problem with Camel 2.11 and Karaf 2.3.1. I have a route, > where I use .loop() and in this route I call a web service which returns > response which I want to keep. I need to keep all responses and then print > them in the output message. After the loop ends, I have only the last > response. > > Here is the route: > > Predicate isServiceEnabled = > property(AddProjectBean.SERVICE_STATUS).isEqualTo(true); > Predicate serviceNeedsUpdate = > property(AddProjectBean.SERVICE_NEEDS_UPDATE).isEqualTo(true); > from("direct:addNextProjects") > .routeId("addNextProjects") > .choice() > .when(isServiceEnabled) > .beanRef("addProjectBean", "setServiceLoopIndex") > .choice() > .when(serviceNeedsUpdate) > > .loop(property(AddProjectBean.CAMEL_LOOP_SIZE_PROPERTY)) > > .setProperty(AddProjectBean.SERVICE_INDEX_PROPERTY, > property(ProductUpdateBean.CAMEL_LOOP_INDEX_PROPERTY)) > .beanRef("addProjectBean", > "incrementServiceIndex") > .to("direct:createNewProject") > .endChoice() > .otherwise() > .setBody(constant("SERVICE doesn't need > updating")) > .end() > .endChoice() > .otherwise() > .setBody(constant("SERVICE is not enabled")); > > I need to save response body from .to("direct:createNewProject") after each > loop and in the end to have a property, header or something which will > contain all responses, according to the number of loops. So if I add two > new > services, I will have two responses saved somewhere. > > Thank you for any idea > > -Br, Roman > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Loop-saving-responses-tp5751918.html > Sent from the Camel - Users mailing list archive at Nabble.com. >
