【问题标题】:How to filter messages in apache camel如何过滤apache骆驼中的消息
【发布时间】:2011-08-27 12:17:01
【问题描述】:

在我使用 apache camel (mavenized, spring dsl) 构建的应用程序中,我正在阅读来自 一个队列,根据payload中数据的某些条件,大约有3/5的消息需要被丢弃。

但我是 apache camel 的新手,不知道如何调用 bean 的方法并基于 返回值 (boolean) ,如果为 true,则将消息转发到下一个 bean 进行处理。

JMS队列=>过滤器(Bean的方法)=>(真)=>Bean(处理数据)

【问题讨论】:

    标签: filter apache-camel


    【解决方案1】:

    message filter pattern

    from("jms:queue:start")
        .filter().method(MyBean.class, "isGoldCustomer").to("bean:process");
    
    public static class MyBean {
        public boolean isGoldCustomer(@Header("level") String level) { 
            return level.equals("gold"); 
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-15
      • 2013-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-19
      相关资源
      最近更新 更多