gpt4 book ai didi

java - Spring Integration 使用 activeMQ 发送但未接收消息

转载 作者:行者123 更新时间:2023-12-01 14:19:42 25 4
gpt4 key购买 nike

我想在消息发送到 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);
}

最佳答案

你的配置非常适合我;我建议你打开TRACE级别的日志记录来查看双方的消息流。 (TRACE 提供接收端消息监听器容器 Activity 的详细信息)。

如果您使用内存中的 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>

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

关于java - Spring Integration 使用 activeMQ 发送但未接收消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17722404/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com