有没有办法通过该消息中指定的操作来路由 ServiceMix 消息?
我试过用谷歌搜索它,但找不到任何方法来完成这个简单的任务,也许我一开始就做错了?
我有一个发送 2 类消息的适配器。其他 2 个适配器必须捕获它们并给出响应。两条消息具有相同的正文(例如 let it be some <product>...</product>
),但操作不同(例如update
and create
)。如何将该消息路由到不同的适配器?
提前致谢。
有没有办法通过该消息中指定的操作来路由 ServiceMix 消息?
我试过用谷歌搜索它,但找不到任何方法来完成这个简单的任务,也许我一开始就做错了?
我有一个发送 2 类消息的适配器。其他 2 个适配器必须捕获它们并给出响应。两条消息具有相同的正文(例如 let it be some <product>...</product>
),但操作不同(例如update
and create
)。如何将该消息路由到不同的适配器?
提前致谢。
使用 Camel XPath 谓词 (http://camel.apache.org/xpath.html)。例如:
from("queue:products").
choice().xpath("/product/[@create='true']")).to("queue:create").
otherwise().to("queue:update");
在这里找到了答案:http: //fernandoribeiro.eti.br/2009/06/06/multiple-operations-in-apache-camel-routes/
import org.apache.camel.builder.RouteBuilder;
public final class SampleRouteBuilder extends RouteBuilder {
public void configure() {
from("jbi:service:http://www.fernandoribeiro.eti.br/SampleService")
.choice()
.when(header("jbi.operation")
.isEqualTo("{http://www.fernandoribeiro.eti.br}FirstOperation"))
.when(header("jbi.operation")
.isEqualTo("{http://www.fernandoribeiro.eti.br}SecondOperation"));
}
}