package com.zksy.pole.startServer;


import com.zksy.pole.MQTTServer.server.MQTTServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author ShaoYang
 * @date 2024/03/13 15:58
 */
@Component
public class startSrver {

    @Autowired
    private MQTTServer mqttServer;

    @PostConstruct
    public void startNetty(){
        ThreadPoolExecutor threadPoolExecutor=new ThreadPoolExecutor(
                3,
                3,
                60,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<Runnable>(3));
        threadPoolExecutor.execute(new Runnable() {
            @Override
            public void run() {
                try {
                    mqttServer.start();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
}
