我有一个JMS出站网关,它通过请求队列发送消息,并通过响应队列接收消息。我想知道将限制应用于响应队列中消息的接收部分的最简单方法是什么。我尝试为出站网关设置Poller
,但是当我设置它时,根本不会使用响应消息。是否可以在出站网关中使用Poller
来限制消息使用?如果是这样,如何?如果没有,如何最好地限制消息响应消耗?
我的堆栈是:
o.s.i:spring-integration-java-dsl:1.0.0.RC1
o.s.i:spring-integration-jms:4.0.4.RELEASE
My IntegrationgConfig.class:
@Configuration
@EnableIntegration
public class IntegrationConfig {
...
@Bean
public IntegrationFlow testFlow() {
return IntegrationFlows
.from("test.request.ch")
.handle(Jms.outboundGateway(connectionFactory)
.receiveTimeout(45000)
.requestDestination("REQUEST_QUEUE")
.replyDestination("RESPONSE_QUEUE")
.correlationKey("JMSCorrelationID"), e -> {
e.requiresReply(true);
e.poller(Pollers.fixedRate(1000).maxMessagesPerPoll(2)); // when this poller is set, response messages are not consumed at all...
})
.handle("testService",
"testMethod")
.channel("test.response.ch").get();
}
...
}
干杯下午
由于您要从response queue
获取消息,因此.poller()
对您没有帮助。
我们需要poller
端点的input-channel
(在您的情况下test.request.ch
)是否为PollableChannel
。请参阅有关此事的文档。
Jms.outboundGateway
上.replyContainer()
选项供您选择。有了它,您可以配置concurrentConsumers
选项以实现更好的吞吐量 response queue
.
否则,JmsOutboundGateway
将为每个请求消息创建MessageConsumer
。