Helius
2021-08-05 fdb91cc72f7cbe8c095a1ce6442c9259ff01ff06
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.xzx.gc.rabbitmq;
 
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
 
/**如果消息没有到exchange,,ack=false
 
 如果消息到达exchange,,ack=true
 
 
 * @author wangzhongqiu
 *         Created on 2017/10/31.
 * @description:消息发送到交换机监听类
 */
@Service
@Slf4j
public class ConfirmCallBackListener implements RabbitTemplate.ConfirmCallback {
 
    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
        if (ack) {
            log.debug("Success... 消息成功发送到交换机! correlationData:{}", correlationData);
        } else {
            log.debug("Fail... 消息发送到交换机失败! correlationData:{}", correlationData);
        }
 
    }
}