【发布时间】:2017-04-12 10:34:11
【问题描述】:
我有一个 JMS 出站网关,用于将消息发送到队列管理器中的多个队列。使用destinationExpression 方法即时确定目的地:
@Bean
public IntegrationFlow sendTo101() {
return flow -> flow
.handle(Jms
.outboundAdapter(context.getBean("connection101", ConnectionFactory.class))
.destinationExpression("headers.destinationName")
.configureJmsTemplate(spec -> spec
.explicitQosEnabled(true)
.get().setDeliveryDelay(180000)
)
.get(),
endpointSpec -> endpointSpec.advice(context.getBean(RequestHandlerRetryAdvice.class))
);
}
现在需要为传入的消息的某个子集设置传递延迟。有没有办法使用消息的内容来确定我是否应该添加延迟?
我可以有一个过滤器进一步检查此属性并将流重定向到另一个出站网关,但这将是相当多的冗余代码,所以我想确保没有更好的方法。
此外,不同的消息需要不同的延迟。是否可以为每条消息设置不同的延迟?我确实意识到延迟属性在消息生产者上,而不是您根据 JMS 规范在消息上设置的东西,但是我可以为每条消息创建一个新的 JMS 生产者,即使它会妨碍性能。
感谢您的帮助!
【问题讨论】:
标签: java spring spring-integration