//package com.yeejoin.amos.boot.module.hygf.biz.emqx;
//
//
//import com.alibaba.fastjson.JSONObject;
//import com.yeejoin.amos.component.robot.AmosRequestContext;
//import lombok.extern.slf4j.Slf4j;
//import org.eclipse.paho.client.mqttv3.MqttMessage;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.stereotype.Component;
//import org.springframework.transaction.TransactionDefinition;
//import org.springframework.transaction.annotation.Transactional;
//import org.typroject.tyboot.component.emq.EmqKeeper;
//import org.typroject.tyboot.component.emq.EmqxListener;
//import org.typroject.tyboot.core.foundation.context.RequestContext;
//import javax.annotation.PostConstruct;
//import java.util.concurrent.BlockingQueue;
//import java.util.concurrent.LinkedBlockingQueue;
//
///**
// * 告警消息数据处理
// *
// * @author Administrator
// */
//    @Component
//    @EnableScheduling
//    @Slf4j
//    public class DealerExamineMessageService extends EmqxListener {
//
//    @Autowired
//    protected EmqKeeper emqKeeper;
//    @Autowired
//    AmosRequestContext amosAuth;
//
//    @Autowired
//    AmosRequestContext amosRequestContext;
//
//    @Autowired
//    private TransactionDefinition transactionDefinition;
//
//
//    private static final BlockingQueue<JSONObject> blockingQueue = new LinkedBlockingQueue<JSONObject>();
//
//    @PostConstruct
//    void init() throws Exception {
//    new Thread(task_runnable).start();
//    emqKeeper.subscript("DEALER_EXAMINE", 2, this);
//    }
//
//    Runnable task_runnable = new Runnable() {
//    @Override
//    public void run() {
//        boolean isRun = true;
//        int k = 0;
//        while (isRun) {
//        k++;
//        isRun = k < Integer.MAX_VALUE;
//        try {
//            JSONObject analysisResult = blockingQueue.take();
//            RequestContext.setAppKey(amosAuth.getAppKey());
//            RequestContext.setProduct(amosAuth.getProduct());
//            RequestContext.setToken(amosAuth.getToken());
//            processEvent(analysisResult);
//        } catch (Exception e) {
//        e.printStackTrace();
//        }
//        }
//        }
//    };
//
//
//    //解析预警消息
//    @Transactional
//    public void processEvent(JSONObject analysisResult) {
//
//    }
//
//    @Override
//    public void processMessage(String topic, MqttMessage message) throws Exception {
//        System.out.println(message);
//
//        JSONObject analysisResult = JSONObject.parseObject(new String(message.getPayload()));
//        blockingQueue.add(analysisResult);
//    }
//
//
//
//
//
//
//    }
