package com.tax.file.service.async.down;

import com.rabbitmq.client.Channel;
import com.tax.file.model.DownFileModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class FixFileDownReceiver {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private FixFileDownService fixFileDownService;

    @RabbitListener(queues="${spring.rabbitmq.queue.testFixDownFile}",containerFactory="rabbitListenerContainerFactory")
    public void process(DownFileModel model, Channel channel, @Headers Map<String, Object> headers) throws Exception {
        logger.info("FixFileDownReceiver beans:" + model);

        fixFileDownService.execute(model);
    }
}
