Warm tip: This article is reproduced from serverfault.com, please click

java-使用spring集成从activemq队列中消耗消息

(java - consuming message from activemq queue using spring integration)

发布于 2020-12-07 13:51:59

所以我有使用Spring集成将消息发送到activemq队列的应用程序。

 <int-feed:inbound-channel-adapter id="feedAdapter"
                                      channel="feedChannel"
                                      auto-startup="${auto.startup:true}"
                                      url="https://stackoverflow.com/feeds/question/49479712">
        <int:poller fixed-rate="10000"/>
    </int-feed:inbound-channel-adapter>

    <int:channel id="feedChannel"/>

    <int:transformer id="transformer" input-channel="feedChannel"
                     expression="payload.title + payload.author + '#{systemProperties['line.separator']}'"
                     output-channel="feedOutputChannel"/>

    <int:channel id="feedOutputChannel"/>

    <jms:outbound-gateway id="jmsOutGateway"
                          request-destination="inputQueue"
                          request-channel="feedOutputChannel"
                          requires-reply="false"/>

但是现在我想创建一个不同的应用程序,该应用程序使用该队列中的消息,并通过Spring集成将其输出到控制台。我做了这个:

  <jms:message-driven-channel-adapter id="JMSInboundAdapter" destination="inputQueue"/>

    <bean id="inputQueue" class="org.apache.activemq.command.ActiveMQQueue">
        <constructor-arg value="input.queue"/>
    </bean>

当我运行将消息发送到队列的应用程序时,它可以工作。但是当我运行消息消耗应用程序时却没有。我得到的错误:Dispatcher has no subscribers for channel 'application.JMSInboundAdapter'.

我如何配置我的消息使用者应用程序?
Questioner
uyuola
Viewed
11
Gary Russell 2020-12-07 22:41:07

如果channel适配器上没有,则将id成为通道名称。

你需要一些内容来订阅该频道(例如<service-activator inputChannel="JMSInboundAdapter" ... />)。