Guest User

Untitled

a guest
Nov 20th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. package com.github.leosilvadev.verticle;
  2.  
  3. import io.vertx.core.AbstractVerticle;
  4. import io.vertx.core.DeploymentOptions;
  5. import io.vertx.core.Vertx;
  6.  
  7. import java.util.concurrent.atomic.AtomicLong;
  8.  
  9. /**
  10. * Created by leonardo on 11/18/17.
  11. */
  12. public class HelloVerticle extends AbstractVerticle {
  13.  
  14. @Override
  15. public void start() throws Exception {
  16. final Long id = counter.incrementAndGet();
  17. System.out.println(String.format("Verticle number %s running! Worker thread: %s", id, Thread.currentThread().getName()));
  18. vertx.executeBlocking(future -> {
  19. System.out.println(String.format("Verticle number %s running executeBlocking! Worker thread: %s", id, Thread.currentThread().getName()));
  20. future.complete(true);
  21. }, (result) -> {});
  22. }
  23.  
  24. public static final AtomicLong counter = new AtomicLong(0);
  25.  
  26. public static void main(String[] args) throws InterruptedException {
  27. final Vertx vertx = Vertx.vertx();
  28.  
  29. vertx.deployVerticle(HelloVerticle.class.getName());
  30.  
  31. Thread.sleep(1000);
  32. System.out.println("\n");
  33. vertx.deployVerticle(HelloVerticle.class.getName(), new DeploymentOptions().setWorker(true).setInstances(10));
  34.  
  35. Thread.sleep(1000);
  36. System.out.println("\n");
  37. vertx.deployVerticle(HelloVerticle.class.getName(), new DeploymentOptions().setWorker(true).setInstances(10).setWorkerPoolSize(100));
  38.  
  39. Thread.sleep(1000);
  40. System.out.println("\n");
  41. vertx.deployVerticle(HelloVerticle.class.getName(), new DeploymentOptions().setWorker(true).setInstances(10).setWorkerPoolSize(100).setWorkerPoolName("newOne"));
  42. }
  43.  
  44. }
Add Comment
Please, Sign In to add comment