package com.mortals.xhx.base.framework.listener;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Service;

/**
 * @author: zxfei
 * @date: 2022/8/23 0:32
 * @description:
 **/
@Slf4j
@Service
public class SimpleDynamicListener implements ChannelAwareMessageListener {

    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        String queue = message.getMessageProperties().getConsumerQueue();
        byte[] body = message.getBody();
        log.info("接收到：" + queue + "，消息内容为：" + new String(body));
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
        log.info(queue + "队列消息消费成功");
    }
}
