繁体   English   中英

使用ActiveMQ发送但未收到的Spring Integration消息

[英]Spring Integration Messages sent but not received with activeMQ

当消息发送到FORWARD队列/从FORWARD队列接收消息时,我想创建一个简单的测试。 收到消息后,应调用服务。

不幸的是,消息是通过Message<?> message = MessageBuilder.withPayload(params); forwardGateway.sendPremMessage(message); Message<?> message = MessageBuilder.withPayload(params); forwardGateway.sendPremMessage(message); 但没有收到。

这是我的配置:

  <!-- SENDER -->

<si:gateway id="forwardGateway" 
    service-interface="com.ucware.ucpo.forward.jms.MessageGateway" 
    default-request-channel="inputChannel"/>

<si:channel id="inputChannel"/>

    <!-- Subscriber to a channel -->
<int-jms:outbound-channel-adapter 
channel="inputChannel"
connection-factory="connectionFactory" 
destination-name="FORWARD" />


<!-- RECEIVER -->
<int:channel id="jmsInChannel"/>

 <!-- Subscriber to jmsInChannel. Used instead of inboud channel adapter -->
<int-jms:message-driven-channel-adapter id="messageDrivenAdapter"
    channel="jmsInChannel" destination-name="FORWARD" connection-factory="connectionFactory"
    concurrent-consumers="1" auto-startup="true" acknowledge="auto"/>

 // This service should be invoked but it is not 
<si:service-activator id ="activator" 
    input-channel="jmsInChannel"
    ref="messageService" 
    method="process"/>

该服务定义为:

@MessageEndpoint
public class MessageService   {

public void process(Message<?> message )  

},网关为:

public interface MessageGateway  {

@Gateway 
public void sendPremMessage(Message<?> message);
}

您的配置对我来说很好用; 我建议您打开TRACE级别日志记录以查看双方的消息流。 (TRACE给出了接收方的消息侦听器容器活动的详细信息)。

如果您使用内存中的ActiveMQ,则需要注意时间安排-在容器启动之前不要发送消息。 另外,请确保使用CachingConnectionFactory

<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
    <property name="targetConnectionFactory">
        <bean class="org.apache.activemq.ActiveMQConnectionFactory">
            <property name="brokerURL" value="vm://localhost"/>
        </bean>
    </property>
</bean>

这样,即使容器尚未启动,代理也将在发送后保持运行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM