赞
踩
springboot.rabbitmq.publisher-confirm 新版本已被弃用,现在使用 spring.rabbitmq.publisher-confirm-type = correlated 实现相同效果
在springboot2.2.0.RELEASE版本之前是amqp正式支持的属性,用来配置消息发送到交换器之后是否触发回调方法,在2.2.0及之后该属性过期使用spring.rabbitmq.publisher-confirm-type属性配置代替,用来配置更多的确认类型;
1.spring.rabbitmq.publisher-confirm发布确认属性配置
如果该属性为true,则会触发以下方法:
- /**
- * 设置生产者消息publish-confirm回调函数
- */
- rabbitTemplate.setConfirmCallback((correlationData, ack, cause) -> {
- if(!ack){
- LoggerUtil.error(RabbitConfig.class, StringUtils.join("publishConfirm消息发送到交换器被退回,Id:", correlationData.getId(), ";退回原因是:", cause));
- } else {
- LoggerUtil.info(RabbitConfig.class, "发送消息到交换器成功,MessageId:"+correlationData.getId());
- }
- });
2.spring.rabbitmq.publisher-confirm-type新版发布确认属性有三种确认类型
- /**
- * The type of publisher confirms to use.
- */
- public enum ConfirmType {
-
- /**
- * Use {@code RabbitTemplate#waitForConfirms()} (or {@code waitForConfirmsOrDie()}
- * within scoped operations.
- */
- SIMPLE,
-
- /**
- * Use with {@code CorrelationData} to correlate confirmations with sent
- * messsages.
- */
- CORRELATED,
-
- /**
- * Publisher confirms are disabled (default).
- */
- NONE
-
- }
GitHub地址:https://github.com/mingyang66/spring-parent/tree/master/doc/rabbitmq
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。