【发布时间】:2016-09-15 20:05:52
【问题描述】:
从我使用骆驼的弹簧靴中,我想知道是否有可能在骆驼路线完成时获得响应(我的示例中的最后一条路线)。它开始像这样使用 ProducerTemplate:
@Component
public class CamelSender {
@Produce(uri = "direct:start")
private ProducerTemplate template;
public void callRoute(List<String> list) throws ExecutionException, InterruptedException {
template.sendBodyAndHeader("direct:start", list, "orderId", "123456677"
);
}
}
//骆驼路线
from("direct:start")
.log("Split -> Process order ${body}")
.split().body().to("direct:actionQueue")
.end();
from("direct:actionQueue")
.bean(ValidateOrders.class)
.log("Sending to join queue")
.to("direct:joinQueue");
from("direct:joinQueue").aggregate(new MyOrderAggregationStrategy())
.header("orderId")
.completionTimeout(1000L)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
List<String> orders = ( (List<String>) exchange.getIn().getBody());
String collect = orders.stream().map(order -> order.toString()).collect(Collectors.joining(","));
exchange.getIn().setBody( "Collected validations: "+collect);
}
})
.log("${body}");
如何将带有收集到的验证(字符串)的主体返回给我的 java bean?
【问题讨论】: