简单配置rabbitmq参数
java
spring:
rabbitmq:
host: 192.168.1.2
port: 5672
username: guest
password: guest
publisher-confirms: true
virtual-host: print_test
发送消息和接收消息虽然能成功,但是监听器接收消息确认后一直会打印如下错误
Shutdown Signal: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - unknown delivery tag 0, class-id=60, method-id=80
增加配置后问题得到解决
java
1spring:
rabbitmq:
host: 192.168.1.2
port: 5672
username: guest
password: guest
publisher-confirms: true
virtual-host: print_test
listener:
simple:
acknowledge-mode: manual
retry:
#60秒后重试
initial-interval: 60000
#启用发布重试
enabled: true
#传递消息的最大尝试次数
max-attempts: 3
#尝试的最大时间间隔
max-interval: 60000
#应用于先前传递重试时间间隔的乘数
multiplier: 1.0
推测原因是未设置acknowledge-mode: manual手动确认消息,而在代码中手动确认了消息。