package com.yeejoin.amos.boot.module.jcs.biz.activeMq;

import com.yeejoin.amos.boot.module.jcs.api.service.ICcsToStationUserInfo;
import com.yeejoin.amos.boot.module.jcs.biz.config.StartLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import javax.jms.TextMessage;

/**
 * @author DELL
 */
@Component
public class QueueConsumerService {
    private final Logger logger = LoggerFactory.getLogger(StartLoader.class);

    @Autowired
    ICcsToStationUserInfo ccsToStationUserInfo;

    @JmsListener(destination = "amos.privilege.v1.STATE_GRID.AMOS_ADMIN.login", containerFactory = "jmsListenerContainerQueue")
    public void message(TextMessage textMessage) {
        try {
            if(textMessage == null || textMessage.getText() == null){
                return;
            }
            logger.info("收到activeMQ发送登录信息>>{}", textMessage.getText());
            ccsToStationUserInfo.sendUserInfoToStation(textMessage.getText());
        } catch (Exception e) {
            logger.error("消费activeMQ发送登录信息失败，{}", e.getMessage());
        }
    }
}
