package com.persagy.bdtp.adm.handler;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.persagy.bdtp.adm.common.AdmMessageConst;
import com.persagy.dmp.amqp.handler.AbstractRabbitHandlerTemplate;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Slf4j
@Component
@RabbitListener(queues = AdmMessageConst.M2D_QUEUE)
public class M2DMessageHandler extends AbstractRabbitHandlerTemplate {

    @Autowired
    private ObjectMapper objectMapper;

    /**
     * 消费
     * @param message 消息体字符串
     * @param channel 通道对象
     * @param vo     消息对象
     */
    @Override
    protected void handler(String message, Channel channel, Message vo) {
        //objectMapper.readValue(message, ProjectMessageVO.class);
        System.out.println(new Date() + ": " + message);
    }

}
