在我的应用程序构建中使用apache camel(mavenized,spring dsl),我正在阅读来自的消息 在队列中,需要根据有效载荷中的数据中的某些条件丢弃大约3/5的消息。
但我是apache camel的新手,并且不知道如何调用bean的方法并且基于 返回值(布尔值),如果为true则将消息转发到下一个bean进行处理。
JMS queue =>过滤器(Bean的方法)=> (true)=> Bean(过程数据)
答案 0 :(得分:3)
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");
}
}