Apache camel 如何在apache camel中全局设置exchange属性
例如:Apache camel 如何在apache camel中全局设置exchange属性,apache-camel,apache-karaf,apache-servicemix,Apache Camel,Apache Karaf,Apache Servicemix,例如: 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);
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中的endpoint1获得的响应。您的问题已经有了答案,使用它,您可以从exchange获得您想要的任何路由。还考虑在最后的路径中移除属性。 您的问题已经有了答案,可以使用,您可以从交易所获得您想要的任何路线。还考虑在最后的路径中移除属性。 你可以这样做
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);
可以将原始实体保存在特性中,也可以保存endpoint1中的实体。然后将交换发送到direct:req2,原始主体在exhcnage主体中,主体形式endpoint1在属性中,然后可以在处理器或其他位置访问该属性
要访问处理器中的属性,请执行以下操作:
public void process(final Exchange exchange) throws Exception {
Object body = exchange.getProperty("endpoint1.body");
}
你可以这样做
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);
可以将原始实体保存在特性中,也可以保存endpoint1中的实体。然后将交换发送到direct:req2,原始主体在exhcnage主体中,主体形式endpoint1在属性中,然后可以在处理器或其他位置访问该属性
要访问处理器中的属性,请执行以下操作:
public void process(final Exchange exchange) throws Exception {
Object body = exchange.getProperty("endpoint1.body");
}
有没有办法设置在所有处理器中全局可用的属性?有没有办法设置在所有处理器中全局可用的属性?