package com.ruoyi.xq.mq;

import com.alibaba.fastjson.JSON;
import com.ruoyi.xq.mq.consumer.CommonConsumer;
import com.ruoyi.xq.mq.handle.dto.CommonDTO;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class AmqpProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;


    public <T extends CommonDTO> void sendCommonMq(T dto){
        rabbitTemplate.convertAndSend(CommonConsumer.COMMON_EXCHANGE,
                CommonConsumer.COMMON_KEY, JSON.toJSONString(dto));
    }

}
