简体   繁体   English

使用选择器的Spring Integration JMS消息驱动的通道适配器

[英]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 . 使用消息驱动适配器,我想使用选择器过滤来自AMQ代理的消息。

message has to filtered against dynamic bean variable value which is validated using selector bean ref option 消息必须针对使用选择器bean ref选项验证的动态bean变量值进行过滤

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) . 我能够在选择器属性@ bean.method()中调用bean方法,但无法将标头参数传递给该方法@ 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. 我希望选择器应该验证将标头参数动态传递给bean方法并返回布尔结果,以便可以过滤消息。

<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 . 上面的选择器属性的bean方法配置为每当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... 您似乎不了解什么是JMS消息选择器...

selector="foo='bar'"

...tells the broker to only send messages with the foo property equal to bar . ...告诉经纪人仅发送foo属性等于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). 您可以使用丢弃通道将被忽略的消息重新发布到另一个队列(或对它们执行其他操作)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring Integration,JMS入站通道适配器和事务 - Spring Integration, JMS Inbound channel adaptor and transactions Spring集成JMS消息“驱动通道适配器”以使用Java配置连接到IBM MQ - Spring integration JMS message Driven Channel Adapter to connect to IBM MQ using java configuration spring集成消息驱动通道适配器 - spring integration message-driven-channel-adapter Spring Integration Kafka消息驱动通道适配器接收消息 - Spring Integration Kafka message-driven-channel-adapter receive message 使用 jms:inbound-channel-adapter 使用 spring 集成向发件人发送自定义确认消息 - Send Custom Acknowledgement message to sender using jms:inbound-channel-adapter using spring integration 使用Spring Integration Java配置创建消息驱动的入站通道适配器以连接到Kafka - Creating a message driven inbound channel adapter to connect to Kafka using Spring integration java configuration 使用 spring 集成消息驱动的通道适配器配置 AtomikosConnectionFactoryBean - Configuring AtomikosConnectionFactoryBean with spring integration message driven channel adapter Java DSL中具有“选择器”创建功能的“ int-jms:message-driven-channel-adapter” - 'int-jms:message-driven-channel-adapter' with 'selector' creation in Java DSL 在运行时启动jms消息驱动的通道适配器 - Starting jms message driven channel adapter at runtime 保护JMS消息驱动通道适配器 - Securing JMS message-driven-channel-adapter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM