我在官方文档没找到可以通过配置 设置ConfirmListener和returnListener的方法,如果实在需要通过配置文件来设置ConfirmListener和returnListener,可以试试使用xml声明rabbitTemplate,并在xml里调用两个set方法。(这个办法我也没有试过)
Returns are sent to the client by it registering a RabbitTemplate.ReturnsCallback by calling setReturnsCallback(ReturnsCallback callback).
Confirms are sent to the client by it registering a RabbitTemplate.ConfirmCallback by calling setConfirmCallback(ConfirmCallback callback).
参考:
官方文档:https://docs.spring.io/spring-amqp/docs/current/reference/html/#template-confirms
Spring 在applicationContext.xml文件中调用某个对象的方法并赋值:
https://blog.csdn.net/MRZZXzzx/article/details/77513106