当出现问题而不是重新排队时,如何设置侦听器容器何时 channelTransacted(true) 将消息放入死信队列?当我不使用 channelTransacted 时,一切正常,我可以在死信队列中看到消息。
@Bean(name = "amqpInboundEsignRequest")
public IntegrationFlow amqpInbound(ConnectionFactory connectionFactory, PlatformTransactionManager transactionManager) {
return IntegrationFlows.from(
Amqp.inboundAdapter(connectionFactory, esignIAutoRequestQueue())
.acknowledgeMode(AcknowledgeMode.AUTO)
.messageConverter(new Jackson2JsonMessageConverter())
.autoStartup(false)
.defaultRequeueRejected(false)
//.channelTransacted(true) // dead letter does not work
//.transactionManager(transactionManager) // dead letter does not work
)
.log("amqpInbound.start-process")
.handle(p -> {
throw new RuntimeException("Something wrong!");
})
.get();
}
编辑
这些是依赖项的版本。
[INFO] +- org.springframework.boot:spring-boot-starter-amqp:jar:1.5.9.RELEASE:compile
[INFO] | +- org.springframework:spring-messaging:jar:4.3.13.RELEASE:compile
[INFO] | \- org.springframework.amqp:spring-rabbit:jar:1.7.4.RELEASE:compile
[INFO] | +- com.rabbitmq:http-client:jar:1.1.1.RELEASE:compile
[INFO] | +- com.rabbitmq:amqp-client:jar:4.0.3:compile
[INFO] | +- org.springframework.retry:spring-retry:jar:1.2.1.RELEASE:compile
[INFO] | \- org.springframework.amqp:spring-amqp:jar:1.7.4.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-integration:jar:1.5.9.RELEASE:compile
[INFO] | +- org.springframework.integration:spring-integration-core:jar:4.3.12.RELEASE:compile
[INFO] | \- org.springframework.integration:spring-integration-java-dsl:jar:1.2.3.RELEASE:compile
[INFO] | \- org.reactivestreams:reactive-streams:jar:1.0.0:compile
我想让事务与外部事务数据库(PlatformTransactionManager)同步。当我在侦听器容器上设置 transactionManager(transactionManager) 时,它总是会重新排队。