例如:
from("direct:test")
.multicast()
.to("direct:req1","direct:req2");
from("direct:req1")
.to(cxf:bean:endpoint1)
.process("response1");
from("direct:req2")
.process("requestProcessor2")
.to(cxf:bean:endpoint2)
.process(response2);
我是 apache camel 的新手,我只是想知道有什么方法可以使用我从“requestProcessor2”中的端点 1 获得的响应。
最佳答案
你可以这样做
from("direct:test")
.setProperty("test.body", body())
.to(cxf:bean:endpoint1)
.setProperty("endpoint1.body", body())
.process("response1")
.setBody(exchangeProperty("test.body"))
.to("direct:req2")
from("direct:req2")
.process("requestProcessor2")
.to(cxf:bean:endpoint2)
.process(response2);
您将原始主体保存在一个属性中,还保存了端点 1 中的主体。然后,您将交换发送到 direct:req2,原始正文在 exhcnage 正文中,正文在您可以访问的属性中形成 endpoint1(在您的处理器中或其他地方)。
访问处理器中的属性:
public void process(final Exchange exchange) throws Exception {
Object body = exchange.getProperty("endpoint1.body");
}
https://stackoverflow.com/questions/38410908/