【问题标题】:Keep sending messages in Spring Integration在 Spring Integration 中继续发送消息
【发布时间】:2013-10-14 04:40:32
【问题描述】:

一个模块每 N 秒向消息代理发送消息。另一个模块从代理接收消息。消息构建在服务激活器的方法 sendMessage 中。计划是使用入站通道适配器(如答案中所示),但由于某些原因,此解决方案不起作用,我一直收到“在轮询期间未收到任何消息,返回 'false'”。这个配置有什么问题?

<int-jms:inbound-channel-adapter id="keepAlivePoller" channel="keepAliveChannel" destination="keepAlive" connection-factory="connectionFactory"> 
        <si:poller id="sendPoller"  fixed-rate="${keepalive.sendinterval}" max-messages-per-poll="1"></si:poller>
    </int-jms:inbound-channel-adapter>

    <si:service-activator input-channel="keepAliveChannel" method="sendMessage" ref="keepAliveSender"/>
    <bean class="com.foo.KeepAliveSender"/>

    <si:channel id="keepAliveChannel"/>

【问题讨论】:

  • 你能说明一下“这个解决方案不起作用的一些原因”吗?
  • 当然 :) 我不断收到 [PollingConsumer] [AbstractTransactionSynchronizingPollingEndpoint.java] [DEBUG] [task-scheduler-1] 在轮询期间未收到任何消息,每 N 秒返回 'false'[PollingConsumer]。

标签: spring-integration poller


【解决方案1】:

只有在“keepAlive”队列中有消息时才会发送消息。

您可以简单地使用...

<int:inbound-channel-adapter id="keepAlivePoller" channel="keepAliveChannel"
        expression="'foo'"> 
    <si:poller id="sendPoller"  fixed-rate="${keepalive.sendinterval}" />
</int:inbound-channel-adapter>

...根本不使用 JMS。

【讨论】:

  • 这个解决方案确实有效。我需要使用 JMS,因为一个单独的模块将消息发送到 ActiveMQ 代理,而另一个模块接收它们。
  • 正确,但只有在keepAlive 队列中确实有消息时它才会“工作”。您将不断收到Received no message...,直到存在为止。
  • 我用 Spring 调度器把它整理出来。感谢您的反馈。
猜你喜欢
  • 1970-01-01
  • 2017-04-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-24
  • 2019-06-08
  • 2015-07-08
  • 1970-01-01
相关资源
最近更新 更多