package com.diagbot.rabbit;

import com.diagbot.entity.SysLog;
import com.diagbot.facade.SysLogFacade;
import com.diagbot.util.GsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;

/**
 * @Description: 消费者
 * @author: gaodm
 * @time: 2018/8/29 14:02
 */
@EnableBinding({MyProcessor.class})
public class MyReceiver {
    @Autowired
    SysLogFacade sysLogFacade;
    @StreamListener(MyProcessor.INPUT_LOG)
    public void inputLog (String message) {
        System.out.println("Received <" + message + ">");
        SysLog sysLog=  GsonUtil.toObject(message, SysLog.class);
        sysLogFacade.save(sysLog);
    }
}
