美文网首页
spring.rabbitmq.publisher-confir

spring.rabbitmq.publisher-confir

作者: hemiao3000 | 来源:发表于2021-02-25 16:48 被阅读0次

    在新版本的 springboot rabbitmq 中 spring.rabbitmq.publisher-confirms 已经失效。需要使用 publisher-confirm-type 替代。

    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
    
        }
    
    • NONE值是禁用发布确认模式,是默认值
    • CORRELATED值是发布消息成功到交换器后会触发回调方法,如1示例
    • SIMPLE值经测试有两种效果,其一效果和CORRELATED值一样会触发回调方法,其二在发布消息成功后使用rabbitTemplate调用waitForConfirms或waitForConfirmsOrDie方法等待broker节点返回发送结果,根据返回结果来判定下一步的逻辑,要注意的点是waitForConfirmsOrDie方法如果返回false则会关闭channel,则接下来无法发送消息到broker;

    相关文章

      网友评论

          本文标题:spring.rabbitmq.publisher-confir

          本文链接:https://www.haomeiwen.com/subject/zqeufltx.html