VerticleLifeCycle.java
775 Bytes
package com.diligrp.mqtt.vertx.config;
import com.diligrp.mqtt.vertx.verticle.MqttVerticle;
import io.vertx.core.Vertx;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
/**
* verticle生命周期
*
* @author zhangmeiyang
* @date 2025/12/30
*/
@Component
public class VerticleLifeCycle implements CommandLineRunner, DisposableBean {
private final Vertx vertx;
public VerticleLifeCycle(Vertx vertx) {
this.vertx = vertx;
}
@Override
public void run(String... args) throws Exception {
vertx.deployVerticle(new MqttVerticle());
}
@Override
public void destroy() throws Exception {
vertx.close();
}
}