| 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);  | 
|         }  | 
|   | 
|     }  | 
| } |