Created
November 18, 2017 21:24
-
-
Save leosilvadev/ff172d7bba5601a934035e0a05d48f1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could you please explain the code and concepts ?