Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Loop - saving responses

$
0
0
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

Viewing all articles
Browse latest Browse all 5648

Trending Articles