package com.muyu.carData.consumer;

import com.muyu.carData.util.CacheUtil;
import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/** 车辆下线消费者
 * @Author：张腾
 * @Package：com.muyu.carData.consumer
 * @Project：cloud-server-8
 * @name：CarOffConsumer
 * @Date：2024/10/4 14:30
 */
@Log4j2
@Component
public class CarOffConsumer {

    @Autowired
    private CacheUtil cacheUtil;

        @RabbitListener(bindings = @QueueBinding(
                value = @Queue(value = "CAR_OFFLINE",durable = "true"),
                exchange = @Exchange(value = "CAR_OFF_EXCHANGE",type = "fanout")
        ))
        public void inline(String vin){
            log.info("车辆vin:{},车辆下线成功!开始消费...");
            cacheUtil.remove(vin);
        }
}
