Java Spring集成的并发性问题;无法发布到已删除的目标";
我有两个应用程序在ActiveMQ代理的任一侧运行;应用程序1向应用程序2发送同步请求,后者将响应返回给应用程序1 应用程序1Java Spring集成的并发性问题;无法发布到已删除的目标";,java,spring,spring-integration,Java,Spring,Spring Integration,我有两个应用程序在ActiveMQ代理的任一侧运行;应用程序1向应用程序2发送同步请求,后者将响应返回给应用程序1 应用程序1 @MessagingGateway public interface OrderGateway { @Gateway(requestChannel = "requestChannel", replyChannel = "responseChannel") public OrderDto fetchOrder(OrderRequest orderRequ
@MessagingGateway
public interface OrderGateway {
@Gateway(requestChannel = "requestChannel", replyChannel = "responseChannel")
public OrderDto fetchOrder(OrderRequest orderRequest);
}
@Bean
public IntegrationFlow outgoingRequestFlow(ConnectionFactory connectionFactory) {
return IntegrationFlows.from("requestChannel")
.handle(Jms.outboundGateway(connectionFactory).requestDestination("order.queue"))
.get();
}
应用程序2
@Bean
public IntegrationFlow incomingRequestFlow(ConnectionFactory connectionFactory) {
return IntegrationFlows.from(Jms.inboundGateway(connectionFactory).destination("order.queue"))
.channel("requestChannel")
.handle("orderServiceActivator", "fetchOrder")
.channel("responseChannel")
.get();
}
@Component
public class OrderServiceActivator {
@Autowired
OrderService orderService;
@ServiceActivator
public OrderDto fetchOrder(OrderRequest orderRequest) {
return orderService.getById(orderRequest.getId());
}
}
两个应用程序都包含以下代理连接工厂配置:
@Bean(destroyMethod = "stop")
public PooledConnectionFactory activeMQConnectionFactory() {
ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory();
activeMQConnectionFactory.setBrokerURL("tcp://broker.local:61616");
return new PooledConnectionFactory(activeMQConnectionFactory);
}
我在应用程序1/myapp/order/{id}
中创建了一个REST控制器,它将请求提交到orderGateway.fetchOrder
,工作正常。然后我通过运行来测试它,而不是true;卷曲http://localhost:8080/myapp/order/1; 在命令行上完成
,并让它运行几分钟,通过应用程序发送数百个请求,没有错误,一切正常。我可以看到,request.queue
在ActiveMQ管理工具中对消息进行排队和出列,而ActiveMQ.advical.TempQueue
也具有较高的排队/出列计数
当存在并发请求时会出现问题;如果打开两个终端窗口并在两个窗口中运行curl循环,我很快就会看到以下错误:
Sep 21, 2015 4:35:25 PM org.springframework.jms.listener.DefaultMessageListenerContainer invokeErrorHandler
WARNING: Execution of JMS message listener failed, and no ErrorHandler has been set.
javax.jms.InvalidDestinationException: Cannot publish to a deleted Destination: temp-queue://ID:Stans-MacBook-Pro.local-64816-1442849675850-1:1:559
我的SI配置是否错误?是否需要应用其他一些配置参数?感谢您的指导。我需要查看双方的调试日志以了解发生了什么-这意味着客户端已超时;但是,默认超时为5秒。您可以增加出站网关上的
receiveTimeout
也就是说,通常最好使用命名的应答目的地,以避免为每个请求创建临时应答队列。请记住,同样的超时也适用于此。谢谢您的回复。我将重点创建一个命名的回复目的地,以查看错误是否仍然存在。我创建了一个单独的问题,而不是编辑这个问题。