package com.xzx.log.queue;
|
|
import cn.hutool.json.JSONUtil;
|
import com.rabbitmq.client.Channel;
|
import com.xzx.log.constants.MqConstants;
|
import com.xzx.log.util.MqUtil;
|
import com.xzx.log.util.RedisUtil;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.amqp.core.Message;
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import java.io.IOException;
|
|
|
/**
|
* 死信队列
|
*/
|
@Component
|
@Slf4j
|
public class DeadConsumer {
|
|
@Autowired
|
private RedisUtil redisUtil;
|
|
@RabbitListener(queues =MqConstants.DEAD_QUEUE)
|
public void process(Message message,Channel channel) throws IOException {
|
long deliveryTag = MqUtil.getTag(message);
|
channel.basicAck(deliveryTag, false);
|
// 获取消息Id
|
redisUtil.rpush(MqConstants.ERR_QUEUE_REDIS,MqUtil.getMsg(message));
|
}
|
|
}
|