package com.winsun.rabbitmq;

import com.winsun.service.ExportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 导出
 *
 * @Date: 2020/3/16 18:26
 */
@Slf4j
@Component
@RabbitListener(queues = "taskImport")
public class ExportConsumer {

    @Autowired
    private ExportService exportService;
    /**
     * 消息消费
     *
     * @RabbitHandler 代表此方法为接受到消息后的处理方法
     */
    @RabbitHandler
    public void recieved(Map<String, Object> map) {
        log.info("执行订单导出任务");
        try {
            exportService.ExportOrderView(map);
        } catch (Exception e) {
            log.error("执行订单导出任务异常",e.getMessage(), e);
        }
        log.info("执行订单导出完成");
    }
}
