Hi all, What I'm trying to do is to authenticate a message before sending it to be processed using message filter, so I have something like
.filter().method(MyAuthenticator.class, "isAuthenticated") However in my route builder, I also route the messages based on their types using choice. So for example I have from(IN_QUEUE).choice() .when(header(JMS_TYPE).isEqualTo("Type1")) .to("bean:myBean?method=handleMessage") .when(header(JMS_TYPE).isEqualTo("Type2")) .to("bean:yourBean?method=handleMessage") .otherwise().to("activemq:myqueue.in.DLQ") .routeId("jms-my-route"); the filter seems to work when I put it before choice, like this from(IN_QUEUE) ..filter().method(ClientAuthenticator.class, "isAuthenticated") .choice() .when(header(JMS_TYPE).isEqualTo("Type1")) .to("bean:myBean?method=handleMessage") .when(header(JMS_TYPE).isEqualTo("Type2")) .to("bean:yourBean?method=handleMessage") .otherwise().to("activemq:myqueue.in.DLQ") .routeId("jms-my-route"); But I want to only authenticate Type1 messages, not Type2 messages. So I tried from(IN_QUEUE).choice() .when(header(JMS_TYPE).isEqualTo("Type1")) .filter().method(ClientAuthenticator.class, "isAuthenticated") .to("bean:myBean?method=handleMessage").end() .when(header(JMS_TYPE).isEqualTo("Type2")) .to("bean:yourBean?method=handleMessage") .otherwise().to("activemq:myqueue.in.DLQ") .routeId("jms-my-route"); But the second when clauses is not valid. Can I use filter inside when?If not, is there another solution? Thanks! xuan