发布和获取 acks/nacks 正在按预期工作。我在这里担心的是,它不会关闭未使用的额外频道。另一方面,当 Publisher Confirms 设置为 false 时,未使用的通道将按预期关闭。
ConnectionFactory 示例:
cachingConnectionFactory.setCacheMode(CachingConnectionFactory.CacheMode.CHANNEL);
cachingConnectionFactory.setChannelCacheSize(confirmChannelCacheSize);
cachingConnectionFactory.setPublisherConfirms(Boolean.TRUE);
cachingConnectionFactory.setPublisherReturns(Boolean.TRUE);
RabbitTemplate 示例:
template.setMandatory(true);
template.setConfirmCallback(deepConfirmCallback);
template.setReturnCallback(returnCallback);
Spring AMQP 依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>