package com.usky.iot.service.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

import java.util.Map;

@Slf4j
@Component
public class RabbitMQListener {


    @RabbitHandler
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(),
            exchange = @Exchange(value = "Patrol_FInfo",type = ExchangeTypes.FANOUT)
    ))
    public void getData(Message message){
        try {
            String str = new String(message.getBody(),"utf-8");
            System.out.println("FanoutReceiver消费者收到心跳消息： " + str);
        } catch (Exception e){
            e.printStackTrace();
        }
    }
}
