所以我有使用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'.
如果channel
适配器上没有,则将id
成为通道名称。
你需要一些内容来订阅该频道(例如<service-activator inputChannel="JMSInboundAdapter" ... />
)。
<jms:message-driven-channel-adapter id="JMSInboundAdapter" destination="inputQueue"/> <int:service-activator input-channel="JMSInboundAdapter" ref="demoBean"/>
我添加了服务激活器,但是现在出现此错误no output-channel or replyChannel header available
,此问题与我的消息生产者或使用者有关吗?您的服务方法需要一个返回类型
void
(或returnnull
)来“结束”流程;否则,如果它返回某个值,则需要一个输出通道(以及一些下游消耗通道)。您也可以设置outputChannel="nullChannel"
为放弃服务输出。