首页 文章

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

提问于
浏览
1

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

其中一个要求是我无法添加新服务或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 回答

  • 1

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

    但这是你的选择,或正如你所说的 requirements .

    改变雇主! ;-)

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

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

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

相关问题