Hello,
I would like to offer a main webservice which gets a http request with xml
payload.
After unmarshalling with JAXB I want to split (splitterBusinessLogic) the
request into 2 subservice requests with dynamic target url's.
Therefore I use a dynamicRouter (with MyDynamicRouter.class).
Finally I have to aggregate both subservice responses
(MyAggregationStrategy) and process the aggregated Objects with
businessLogic4 to a major response of the main webservice.
Sorry I'm a newbie, I didn't get it working. Here is my approach. Is that
the right strategy, at the moment I get:
org.apache.camel.NoSuchEndpointException: No endpoint could be found for:
[here comes result of businessLogic6], please check your classpath contains
the needed Camel component jar.
I think the routing back from dynamikRouting to main route doesn't work ?
Any help would be great !
james
...
.to("direct:splitterBusinessLogic")
.split(body(ArrayList.class), new MyAggregationStrategy())
.stopOnException()
.parallelProcessing()
.executorService(Executors.newFixedThreadPool(5))
.dynamicRouter(method(MyDynamicRouter.class, "slip"))
.end()
.to("direct:businessLogic4")
...
from("direct:call_ws_a")
.to("direct:businessLogic5")
.setHeader(Exchange.HTTP_METHOD, constant("POST"))
.to("http://aaa...")
.unmarshal().custom("jaxbDataFormatInternal2")
.to("direct:businessLogic6");
from("direct:call_ws_b")
.to("direct:businessLogic5")
.setHeader(Exchange.HTTP_METHOD, constant("POST"))
.to("http://bbb...")
.unmarshal().custom("jaxbDataFormatInternal3")
.to("direct:businessLogic6");
----------------------------------------
splitterBusinessLogic:
public class SplitterBusinessLogicRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
from("direct:splitterBusinessLogic")
.process(
new Processor() {
public void process(Exchange exchange) throws
Exception {
...
ArrayList<Map<String, String>> list
= new ArrayList<Map<String,
String>>();
Map<String, String> map1 = new
HashMap<String, String>();
map1.put("A",
"<SUB-REQUEST-AAA>aaa</SUB-REQUEST-AAA>");
list.add(map1);
Map<String, String> map2 = new
HashMap<String, String>();
map2.put("B",
"<SUB-REQUEST-BBB>bbb</SUB-REQUEST-BBB>");
list.add(map2);
exchange.getOut().setBody(list,
ArrayList.class);
}
}
);
}
}
------------------------
MyAggregationStrategy:
public class MyAggregationStrategy implements AggregationStrategy {
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
Object newBody = newExchange.getIn().getBody();
ArrayList list = null;
if(oldExchange == null) {
list = new ArrayList();
list.add(newBody);
newExchange.getIn().setBody(list);
return newExchange;
}
else {
list = oldExchange.getIn().getBody(ArrayList.class);
list.add(newBody);
return oldExchange;
}
}
}
-------------------------
MyDynamikRouter:
public class MyDynamicRouter {
public String slip(Map<String, String> body) {
if(body.containsKey("A")) {
return "direct:call_ws_a";
}
else if(body.containsKey("B")) {
return "direct:call_ws_b";
}
return null;
}
}
--------------------------
businessLogic6:
public class BusinessLogic6RouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
from("direct:businessLogic6")
.process(
new Processor() {
public void process(Exchange exchange) throws
Exception {
Object obj = exchange.getIn().getBody();
String result = null;
...
exchange.getOut().setBody(result);
}
}
);
}
}
--------------------------------------------
businessLogic4:
public class BusinessLogic4RouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
from("direct:businessLogic4")
.process(
new Processor() {
public void process(Exchange exchange) throws
Exception {
ArrayList list =
exchange.getIn().getBody(ArrayList.class);
...
}
}
);
}
}
--
View this message in context:
http://camel.465427.n5.nabble.com/Split-in-combination-with-aggregation-and-dynamicRouter-tp5747671.html
Sent from the Camel - Users mailing list archive at Nabble.com.