package com.muyu.rabbitmq;

import com.muyu.rabbitmq.confilg.RabbitmqConfig;
import com.rabbitmq.client.impl.AMQImpl;
import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;


/**
 * 监听车辆上线的信息 SubscriptionHandler
 *
 * @author Yangle
 * Date 2024/6/6 14:24
 */
@Component
@Log4j2
public class SubscriptionHandler {

    @RabbitListener(queues = {RabbitmqConfig.QUEUE_INFORM_EMAIL})
    public void receive_email(Object msg, Message message, AMQImpl.Channel channel){
        System.out.println("QUEUE_INFORM_EMAIL msg"+msg);
    }
    //监听sms队列
    @RabbitListener(queues = "subscription")
    public void receiveSms(Message message) {
        try {
            log.info("消费者得到的消息: {}" , new String(message.getBody()));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}
