package com.bocloud.ims.booter.listener;

import com.alibaba.fastjson.JSONObject;
import com.bocloud.common.utils.JSONTools;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.nio.charset.Charset;

/**
 * @ClassName: ShtermListener
 * @Description: 堡垒机回调监听
 * @Author lxy
 * @Date 2021/5/13 10:46
 */
@Component
public class ShtermListener {

    private static Logger logger = LoggerFactory.getLogger(ShtermListener.class);

    /** @Author: lxy
     * @Description: 堡垒机接收创建vm回复信息
     * @Date 2021/5/13 10:47
     * @Param message
     * @return void
     * @throws:
     **/
    @RabbitListener(queues = "sync.shterm.callback.queue", admin = "amqpAdmin", autoStartup = "true")
    public void listener1(JSONObject jsonObject) {

        if (null == jsonObject || StringUtils.isBlank(jsonObject.toJSONString())) {
            // 消息没有内容，直接确认收到 淹没处理
            return;
        }
        logger.info("收到堡垒机创建vm回复信息:{}", jsonObject.toJSONString());
    }
}
