package com.ruoyi.rabbitmq.listener;

import com.rabbitmq.client.Channel;
import com.ruoyi.rabbitmq.annotation.RabbitComponent;
import com.ruoyi.rabbitmq.constant.GeneralConstant;
import com.ruoyi.rabbitmq.core.BaseRabbiMqHandler;
import com.ruoyi.rabbitmq.utils.BaseMap;

import com.ruoyi.rabbitmq.utils.MqConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;

import java.io.IOException;

/**
 * RabbitMq接受者4
 * （@RabbitListener声明类上，一个类只能监听一个队列）
 */
@Slf4j
@RabbitComponent(value = "helloReceiver4")
public class HelloReceiver4 extends BaseRabbiMqHandler<BaseMap> {

    @RabbitListener(queues = GeneralConstant.CustomTestConstant.CUSTOM_TEST_QUEUE)
    public void consume(Message message, Channel channel) {
        super.onMessage(message, channel, new MqListener<BaseMap>() {
            @Override
            public void handler(Message message) {
                //业务处理
                String messageId = message.getMessageProperties().getMessageId();
                String orderId = new String(message.getBody());
                log.info("MQ Receiver4，messageId :{}，orderId:{} ", messageId, orderId);
            }
        });
    }

}
