我是 Spring Integration 的新手,正在尝试使用 SI 和 ActiveMQ 执行一个非常基本的生产者/消费者应用程序。
我看到消息正在生成并存储在队列中,但是当消费者(在这种情况下为服务激活器)处理消息并尝试将新消息返回到输出通道时,我不断收到以下警告消息:
11:28:14.425 WARN [DefaultMessageListenerContainer-1][org.springframework.jms.listener.DefaultMessageLis tenerContainer] Execution of JMS message listener failed, and no ErrorHandler has been set.
org.springframework.integration.MessageDeliveryExc eption: Dispatcher has no subscribers for jms-channel jsonResponseChannel.
at org.springframework.integration.jms.SubscribableJm sChannel$DispatchingMessageListener.onMessage(Subs cribableJmsChannel.java:159)
Below is the snapshot of my context xmls :
common-context.xml
---------------------
..............
<bean id="requestQueue" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="INPUT_MSG_QUEUE" />
</bean>
<bean id="responseQueue" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="OUTPUT_MSG_QUEUE" />
</bean>
<int-jms:channel id="jsonGreetingRequests" queue-name="INPUT_MSG_QUEUE" message-driven="true"/>
<int-jms:channel id="jsonResponseChannel" queue-name="OUTPUT_MSG_QUEUE" message-driven="true"/>
<bean name="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFacto ry">
<property name="brokerURL" value="tcp://localhost:61616" />
</bean>
..............
consumer-context.xml
---------------------
.............
<int-jms:message-driven-channel-adapter id="newRequestsInChannelAdapter" destination="requestQueue" channel="jsonGreetingRequests"/>
<!-- <int-jms:inbound-gateway request-channel="jsonGreetingRequests" reply-channel="jsonResponseChannel" request-destination="requestQueue" />-->
<int:chain input-channel="jsonGreetingRequests" output-channel="jsonResponseChannel">
<int:json-to-object-transformer type="com.periscope.samples.service.Message"/>
<int:service-activator method="greetHello">
<bean class="com.periscope.samples.service.impl.HelloWor ldServiceImpl"/>
</int:service-activator>
<int:object-to-json-transformer />
</int:chain>
<stream:stdout-channel-adapter id="greetingsStdOut" channel="jsonResponseChannel"/>
.....................
producer-context.xml
-----------------------
.....
<int:gateway id="greetings"
default-request-channel="greetingRequests"
service-interface="com.periscope.samples.service.Greetings "/>
<int:channel id="greetingRequests"/>
<int:chain input-channel="greetingRequests" output-channel="jsonGreetingRequests">
<int:object-to-json-transformer />
</int:chain>
<int-jms:outbound-channel-adapter id="jmsGreetingsOutChannelAdapter" channel="jsonGreetingRequests" destination="requestQueue"/>
.......
这基本上是一个 msg 字符串,它被包装在用户定义的对象中,然后在 INPUT_MSG_QUEUE 上发送。消费者读取该消息,对其进行处理并在 OUTPUT_MSG_QUEUE 上返回一条新消息。这些是 ActiveMQ 支持的通道和队列。
有人可以说明如何摆脱这些警告,因为在这个特定的用例中,我不希望任何其他订阅者在 output_msg_queue 上监听?
Thanks.