路由通过操作
问题描述:
有没有什么办法来路由通过操作该消息中指定的ServiceMix的消息?路由通过操作
我试过Google搜索它,但无法找到任何方法来完成这个简单的任务,也许我做错了第一位?
我已经得到了调度2种消息类型的适配器。 2个其他适配器必须赶上他们,并作出回应。这两个消息具有相同的主体(例如让它成为一些<product>...</product>
),但操作不同(例如update
和create
)。我如何路由消息不同的适配器?
在此先感谢。
答
找到答案在这里: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"));
}
}
答
使用Camel XPath谓词(http://camel.apache.org/xpath.html)。例如:
from("queue:products").
choice().xpath("/product/[@create='true']")).to("queue:create").
otherwise().to("queue:update");
很抱歉,但我的意思是我的对象JBI运行时,而不是一些自定义的操作。 – bezmax 2011-04-19 06:36:45