【问题标题】:Routing by operation按操作路由
【发布时间】:2011-08-07 18:15:41
【问题描述】:

有没有办法通过该消息中指定的操作来路由 ServiceMix 消息?

我试过用谷歌搜索,但找不到任何方法来完成这个简单的任务,也许我一开始就做错了?

我有一个分派两种类型消息的适配器。其他 2 个适配器必须捕获它们并给出响应。两条消息具有相同的正文(例如让它成为一些<product>...</product>),但操作不同(例如updatecreate)。如何将这些消息路由到不同的适配器?

提前致谢。

【问题讨论】:

    标签: apache-camel esb apache-servicemix


    【解决方案1】:

    使用 Camel XPath 谓词 (http://camel.apache.org/xpath.html)。例如:

    from("queue:products").  
    choice().xpath("/product/[@create='true']")).to("queue:create").
    otherwise().to("queue:update");
    

    【讨论】:

    • 对不起,我的意思是 JBI 操作,而不是对我的对象的一些自定义操作。
    【解决方案2】:

    在这里找到答案: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"));
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-04
      • 1970-01-01
      相关资源
      最近更新 更多