List of usage examples for io.vertx.core Vertx vertx
vertx
From source file:Example1.java
License:Open Source License
public static void main(String... args) { Vertx.vertx().createHttpClient().getNow(80, "vertx.io", "", response -> { response.bodyHandler(System.out::println); });/*from w w w.jav a 2 s .c om*/ }
From source file:app.Main.java
License:Apache License
public static void main(String... args) throws Throwable { Vertx vertx = Vertx.vertx(); TcpEventBusBridge bridge = TcpEventBusBridge.create(vertx, new BridgeOptions().addInboundPermitted(new PermittedOptions().setAddressRegex("sample.*")) .addOutboundPermitted(new PermittedOptions().setAddressRegex("sample.*"))); vertx.eventBus().consumer("sample.dumb.inbox", message -> { JsonObject body = (JsonObject) message.body(); System.out.println(body.encodePrettily()); });//w w w.j a va 2 s. c o m MessageProducer<Object> tickPublisher = vertx.eventBus().publisher("sample.clock.ticks"); vertx.setPeriodic(1000L, id -> { tickPublisher.send(new JsonObject().put("tick", id)); }); vertx.eventBus().consumer("sample.echo", message -> { JsonObject body = (JsonObject) message.body(); System.out.println("Echoing: " + body.encodePrettily()); message.reply(body); }); bridge.listen(7000, result -> { if (result.failed()) { throw new RuntimeException(result.cause()); } else { System.out.println("TCP Event Bus bridge running on port 7000"); } }); }
From source file:com.baldmountain.depot.DbSeed.java
License:Open Source License
public static void main(String[] args) { Vertx vertx = Vertx.vertx(); JsonObject config = new JsonObject().put("db_name", "depot_development"); mongoService = MongoService.create(vertx, config); mongoService.start();/*from w w w. ja v a2s . c o m*/ mongoService.dropCollection("line_items", res1 -> { if (res1.succeeded()) { mongoService.dropCollection("carts", res2 -> { if (res2.succeeded()) { mongoService.dropCollection("products", event1 -> { if (event1.succeeded()) { LinkedList<Product> products = new LinkedList<>(); products.add(new Product("CoffeeScript", "<p>\n" + " CoffeeScript is JavaScript done right. It provides all of JavaScript's " + "functionality wrapped in a cleaner, more succinct syntax. In the first " + "book on this exciting new language, CoffeeScript guru Trevor Burnham " + "shows you how to hold onto all the power and flexibility of JavaScript " + "while writing clearer, cleaner, and safer code.</p>", "/images/cs.jpg", new BigDecimal(36.00).setScale(2, RoundingMode.CEILING))); products.add(new Product("Programming Ruby 1.9 & 2.0", "<p>Ruby is the fastest growing and most exciting dynamic language " + "out there. If you need to get working programs delivered fast, " + "you should add Ruby to your toolbox. </p>", "/images/ruby.jpg", new BigDecimal(49.95).setScale(2, RoundingMode.CEILING))); products.add(new Product("Rails Test Prescriptions", "<p><em>Rails Test Prescriptions</em> is a comprehensive guide to testing " + "Rails applications, covering Test-Driven Development from both a theoretical perspective (why to test) and from a practical perspective " + "(how to test effectively). It covers the core Rails testing tools and procedures for Rails 2 and Rails 3, and introduces popular add-ons, " + "including Cucumber, Shoulda, Machinist, Mocha, and Rcov.</p>", "/images/rtp.jpg", new BigDecimal(34.95).setScale(2, RoundingMode.CEILING))); saveAProduct(products); } else { setDone("Trouble dropping products"); } }); } else { setDone("Trouble dropping carts"); } }); } else { setDone("Trouble dropping line_items"); } }); try { synchronized (lock) { while (!done) lock.wait(); } } catch (InterruptedException e) { e.printStackTrace(); } vertx.close(); }
From source file:com.camelcookbook.runtimes.vertx.Application.java
License:Apache License
public static void main(String[] args) { Vertx vertx = Vertx.vertx(); vertx.deployVerticle(new CamelVerticle()); vertx.deployVerticle(new HttpVerticle()); }
From source file:com.cisco.ef.VertxMain.java
public static void main(final String... args) throws Exception { final ManagedServiceBuilder managedServiceBuilder = createManagedServiceBuilder(); final CountDownLatch latch = new CountDownLatch(1); final Vertx vertx = Vertx.vertx(); vertx.deployVerticle(new VertxMain(managedServiceBuilder), result -> { if (result.succeeded()) { System.out.println("Deployment id is: " + result.result()); } else {//from ww w .j a v a 2s . co m System.out.println("Deployment failed!"); result.cause().printStackTrace(); } latch.countDown(); }); latch.await(5, TimeUnit.SECONDS); logger.info("QBit and Vertx are open for e-Busbies"); }
From source file:com.company.vertxstarter.Bootstrap.java
public static void main(String[] args) { Vertx vertx = Vertx.vertx(); vertx.deployVerticle(new MainVerticle()); Runtime.getRuntime().addShutdownHook(new Thread() { @Override/*w w w. j ava 2s . co m*/ public void run() { vertx.close(); } }); }
From source file:com.dinstone.vertx.web.resolver.RouteResolverExample.java
License:Apache License
public static void main(String[] args) { Vertx vertx = Vertx.vertx(); RouterBuilder builder = RouterBuilder.create(vertx).resolver(new MethodNameRouteResolver()); Router apiRouter = builder.handler(new HelloResource()).build(); Router router = Router.router(vertx).mountSubRouter("/api", apiRouter); vertx.createHttpServer().requestHandler(router).listen(8080); System.out.println("server work on 8080"); System.out.println("access url: http://localhost:8080/api/HelloResource/get"); System.out.println("access url: http://localhost:8080/api/hello/g"); }
From source file:com.example.HelloWorldServer.java
License:Apache License
public static void main(final String[] args) { Vertx vertx = Vertx.vertx(); vertx.deployVerticle(HelloWorldVerticle.class.getName()); }
From source file:com.funmix.service.DriverServiceImpl.java
public DriverServiceImpl(JsonObject config) { this(Vertx.vertx(), config); }
From source file:com.funmix.service.LineServiceImpl.java
public LineServiceImpl(JsonObject config) { this(Vertx.vertx(), config); }