io.quarkus.qe.kafka.VerticleDeployer Maven / Gradle / Ivy
package io.quarkus.qe.kafka;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;
import jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;
import io.quarkus.qe.kafka.config.VertxKProducerConfig;
import io.quarkus.qe.kafka.producers.StockPriceProducer;
import io.quarkus.runtime.StartupEvent;
import io.smallrye.mutiny.vertx.core.AbstractVerticle;
import io.vertx.mutiny.core.Vertx;
@ApplicationScoped
public class VerticleDeployer {
@Inject
VertxKProducerConfig config;
@Inject
StockPriceProducer producer;
public void run(@Observes StartupEvent e, Vertx vertx, Instance verticles) {
vertx.setPeriodic(config.delay(), c -> producer.generate().subscribe());
// Deploy all abstract verticles example.
for (AbstractVerticle verticle : verticles) {
vertx.deployVerticle(verticle).await().indefinitely();
}
}
}