package com.ruoyi.rabbitmq.listener;

import com.rabbitmq.client.Channel;
import com.ruoyi.common.utils.ClassConvertUtils;
import com.ruoyi.rabbitmq.annotation.RabbitComponent;
import com.ruoyi.rabbitmq.constant.DelayedConstant;
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.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;

@Slf4j
@RabbitComponent(value = "helloTimeReceiver2")
public class HelloTimeReceiver2 extends BaseRabbiMqHandler<BaseMap> {

    @RabbitListener(queues = DelayedConstant.CustomTestDelayedConstant.CUSTOM_TEST_DELAYED_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();
//                Long orderId = ClassConvertUtils.objToLong(new String(message.getBody()));
                String orderId = new String(message.getBody());
                log.info("MQ Receiver4，messageId :{}，orderId:{} ", messageId, orderId);
            }
        });
    }

}
