Skip to content

Instantly share code, notes, and snippets.

@leosilvadev
Created November 18, 2017 21:24
Show Gist options
  • Save leosilvadev/ff172d7bba5601a934035e0a05d48f1e to your computer and use it in GitHub Desktop.
Save leosilvadev/ff172d7bba5601a934035e0a05d48f1e to your computer and use it in GitHub Desktop.
package com.github.leosilvadev.verticle;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Vertx;
import java.util.concurrent.atomic.AtomicLong;
/**
* Created by leonardo on 11/18/17.
*/
public class HelloVerticle extends AbstractVerticle {
@Override
public void start() throws Exception {
final Long id = counter.incrementAndGet();
System.out.println(String.format("Verticle number %s running! Worker thread: %s", id, Thread.currentThread().getName()));
vertx.executeBlocking(future -> {
System.out.println(String.format("Verticle number %s running executeBlocking! Worker thread: %s", id, Thread.currentThread().getName()));
future.complete(true);
}, (result) -> {});
}
public static final AtomicLong counter = new AtomicLong(0);
public static void main(String[] args) throws InterruptedException {
final Vertx vertx = Vertx.vertx();
vertx.deployVerticle(HelloVerticle.class.getName());
Thread.sleep(1000);
System.out.println("\n");
vertx.deployVerticle(HelloVerticle.class.getName(), new DeploymentOptions().setWorker(true).setInstances(10));
Thread.sleep(1000);
System.out.println("\n");
vertx.deployVerticle(HelloVerticle.class.getName(), new DeploymentOptions().setWorker(true).setInstances(10).setWorkerPoolSize(100));
Thread.sleep(1000);
System.out.println("\n");
vertx.deployVerticle(HelloVerticle.class.getName(), new DeploymentOptions().setWorker(true).setInstances(10).setWorkerPoolSize(100).setWorkerPoolName("newOne"));
}
}
@El-kady
Copy link

El-kady commented Feb 25, 2018

Could you please explain the code and concepts ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment