com.github.liaomengge.base_common.mq.rabbitmq.callback.MQConfirmCallback Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of base-common-middleware Show documentation
Show all versions of base-common-middleware Show documentation
base common tool for developer
The newest version!
package com.github.liaomengge.base_common.mq.rabbitmq.callback;
import com.github.liaomengge.base_common.helper.mail.MailHelper;
import com.github.liaomengge.base_common.utils.net.LyNetworkUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
/**
* Created by liaomengge on 16/12/19.
*/
@Slf4j
public class MQConfirmCallback implements RabbitTemplate.ConfirmCallback {
private MailHelper mailHelper;
public MQConfirmCallback(MailHelper mailHelper) {
this.mailHelper = mailHelper;
}
@Override
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
//可能存在恶意消息投递攻击
if (!ack) {
log.error("send message to exchange failed, cause ===> {}", cause);
mailHelper.sendTextMail(LyNetworkUtil.getIpAddress() + "/" + LyNetworkUtil.getHostName() +
"-[RabbitMQ Confirm Callback]失败!", cause);
}
}
}