我正在尝试获取与 JMS 一起运行的基本 Spring Integration 配置。
问题是我似乎正在建立连接(根据日志),但我没有收到有关我的主题的任何消息。
这是我的配置:
<!-- Channels -->
<jms:channel id="inputChannel" queue-name="test.queue" connection-factory="connectionFactory"/>
<!-- Consumers -->
<jms:inbound-channel-adapter id="jmsIn" destination="requestQueue" channel="inputChannel" extract-payload="true" connection-factory="connectionFactory">
<integration:poller time-unit="SECONDS" fixed-rate="5"/>
</jms:inbound-channel-adapter>
<integration:service-activator id="testActivator" input-channel="inputChannel" ref="testServiceActivator" auto-startup="true" method="handle">
</integration:service-activator>
<!-- Bean definitions -->
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://127.0.0.1:61616"/>
</bean>
</property>
<property name="sessionCacheSize" value="10"/>
<property name="cacheProducers" value="false"/>
</bean>
<bean id="requestQueue" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg name="name" value="test.topic"/>
</bean>
<bean id="testServiceActivator" class="com.paddypower.financials.integration.PriceDistributionServiceActivator"/>
我已经在根记录器上启用了 DEBUG 级别,它表示 jmsIn
已成功启动并且已连接到 ActiveMQ 服务器,但我没有收到任何消息,无论是 service-activator
或 inbound-channel-adapter
。
我还可以看到生产者正在通过 ActiveMQ Web 界面发送消息。
那么任何人都可以看到配置有什么问题或者知道我可以进一步调试它的方法吗?
谢谢
最佳答案
将 requestQueue 的 bean 定义从 ActiveMQQueue
更改为 ActiveMQTopic
应该可以修复它。
<bean id="requestQueue" class="org.apache.activemq.command.ActiveMQTopic">
<constructor-arg name="name" value="test.topic"/>
</bean>
关于java - Spring 与 JMS 配置集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10979622/