我试图在聚合器完成后得到回复,但出现一个异常,即我没有指定任何聚合器子项,但当我指定 .to() 端点时,我没有收到聚合结果...这可能吗?
Controller :
@SpringBootApplication
@RestController
public class App {
@Produce(uri = "direct:intake")
private ProducerTemplate producerTemplate;
public static void main(final String...args) {
SpringApplication.run(App.class, args);
}
@RequestMapping("/test/{message}")
public String test(@PathVariable String message) {
return this.producerTemplate.requestBodyAndHeader("direct:intake", message, "id", "abc123").toString();
}
}
聚合器:
@Component
public class Aggregator extends RouteBuilder {
@Override
public void configure() throws Exception {
from("direct:intake")
.aggregate(header("id"))
.aggregationStrategy(new AggregationStrategy() {
@Override
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
if (oldExchange == null)
return newExchange;
oldExchange.getIn().setBody(oldExchange.getIn().getBody() + "::" + newExchange.getIn().getBody());
return oldExchange;
}
})
.completionTimeout(5000)
.to("stream:out");
}
}
最佳答案
Twitter 上有人好心地告诉我,聚合器完成的交换不会在回复中返回。
关于java - Apache Camel 聚合器输入输出回复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45089112/