VerticleLifeCycle.java 912 Bytes
package com.diligrp.mqtt.vertx.config;

import com.diligrp.mqtt.vertx.verticle.MqttVerticle;
import io.vertx.core.Vertx;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.mongo.MongoClient;
import io.vertx.redis.client.Redis;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * verticle生命周期
 *
 * @author zhangmeiyang
 * @date 2025/12/30
 */
@Component
public class VerticleLifeCycle implements CommandLineRunner, DisposableBean {

    @Resource
    private Vertx vertx;

    @Override
    public void run(String... args) throws Exception {
        vertx.deployVerticle(new MqttVerticle());
    }

    @Override
    public void destroy() throws Exception {
        vertx.close();
    }
}