【问题标题】:Spring Integration Messages sent but not received with activeMQ使用activeMQ发送但未接收到的Spring集成消息
【发布时间】:2013-07-17 08:11:08
【问题描述】:

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

很遗憾,邮件是通过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);
}

【问题讨论】:

    标签: java jms activemq messaging spring-integration


    【解决方案1】:

    您的配置对我来说非常好;我建议您打开 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>
    

    这样,即使容器尚未启动,代理也会在发送后继续运行。

    【讨论】:

      猜你喜欢
      • 2014-02-23
      • 2013-08-28
      • 2016-03-27
      • 1970-01-01
      • 1970-01-01
      • 2010-09-19
      • 2021-10-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多