如何在apache camel中过滤消息

时间:2011-05-17 19:13:01

标签: filter apache-camel

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

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

JMS queue =>过滤器(Bean的方法)=> (true)=> Bean(过程数据)

1 个答案:

答案 0 :(得分:3)

请参阅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"); 
    }
}