简体   繁体   中英

spring integration JMS message driven channel adaptor using selector

<int-jms:message-driven-channel-adapter>

Using message driven adapter , i want to filter message from AMQ broker using selector .

message has to filtered against dynamic bean variable value which is validated using selector bean ref option

In reply to your comments..

Thanks for your reply , I want to filter message using selector attribute in Message driven channel adaptor . i was able to call bean method inside selector attribute @bean.method() , but not able to pass header parameter to that method @bean.method(header.param) . I am expecting selector should validate dynamically passing the header parameter to bean method and return boolean result so that message can be filtered.

<int-jms:message-driven-channel-adapter connection-factory="connectionFactoryName" 
     destination="destinationName" channel="channelName" 
     selector="#{@bean.method(header.param)}" auto-startup="false"/> 

the above selector attribute has bean method configured to receive header param dynamically whenever pick message from AMQ . but it is syntactically wrong not able to pass header param. can you help?

You don't seem to understand what a JMS message selector is...

selector="foo='bar'"

...tells the broker to only send messages with the foo property equal to bar . It is configured on the consumer during startup.

What you have is not "dynamic". #{...} expressions are evaluated once during context initialization.

What you are trying to do makes no sense; there is no "message" from which to evaluate a header yet. You can't tell the broker which message(s) to send, based on the contents of a message. The filtering is done on the broker before sending the message(s).

If you don't mind "losing" the messages you are not interested in (or are consuming from a topic) and you want to filter the messages you want to process, then add a

<filter ... expression="#{@bean.method(header.param)}" /> 

after the adapter. You could use the discard channel to republish the ignored message(s) to another queue (or do something else with them).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM