Spring Integration Control Bus消息,用于更改JMS入站通道适配器的选择器

时间:2016-09-22 15:34:41

标签: spring-integration spring-jms

我目前正在基于Spring Integration的(版本3.0.1.RELEASE)应用程序上实现一个流程,该应用程序需要将消息存储在JMS队列中以便稍后获取。 为此,我一直在尝试将Spring Integration JMS入站通道适配器与自定义选择器一起使用,然后通过将JMSDestinationPollingSource的JMS选择器更改为包含为标头属性的某个匹配ID来从队列中获取消息。 / p>

其中一个要求是我无法添加新服务或JAVA方法,因此我一直在尝试使用控制总线对其进行排序,但在发送消息时仍然收到相同的错误messageSelector到不同的东西。

入站通道适配器定义:

<int-jms:inbound-channel-adapter id="inboundAdapter"
                                 channel="inboundChannel"
                                 destinationName="bufferQueue"
                                 connection-factory="connectionFactory"
                                 selector="matchingID = 'NO VALUE'">
    <int:poller fixed-delay="1000"/>
</int-jms:inbound-channel-adapter>

消息:

@'inboundAdapter.source'.setMessageSelector("matchingID = 'VALUE'")

错误:

EvaluationException: The method 'public void org.springframework.integration.jms.JmsDestinationPollingSource.setMessageSelector(java.lang.String)' is not supported by this command processor. If usign the Control Bus, consider adding @ManagedOperation or @ManagedAttribute.

其中,AFAIK,意味着JmsDestinationPollingSource类不是控制总线可管理的,因为它没有传递ControlBusMethodFilter。

这种做法是不可行的,还是我缺少的东西?有没有办法只使用SI XML配置文件动态设置选择器?

1 个答案:

答案 0 :(得分:1)

首先,使用Java工具并不允许在Java上编写代码是很奇怪的......

但这是您的选择,或者您说要求

改变雇主! ; - )

这是正确的:控制总线仅允许@ManagedOperation@ManagedAttribute方法。自JmsDestinationPollingSource.setMessageSelector起。我们可以这样做。但是,如果我们能够采用一种不同的方法,它是否有意义呢?

<int:outbound-channel-adapter id="changeSelectorChannel" 
    ref"inboundAdapter.source method="setMessageSelector"/>

其中新的选择器表达式应该作为此频道的消息的payload