vert.x

Ensure that code within CompletableFuture callback executes after

◇◆丶佛笑我妖孽 提交于 2019-12-30 07:47:08
问题 Say I have this: public void foo(){ CompletableFuture.delayedExecutor(1, TimeUnit.MILLISECONDS).execute(() -> { doSomethingA(); }); doSomethingB(); } Is there any guarantee that doSomethingB(); will always run before doSomethingA();? Something tells me with thread pre-emption , it's possible, although unlikely, that doSomethingA() could be run first? 回答1: No, there is no guarantee, when on a machine which has multiple processors, that doSomethingB() would always execute before doSomethingA().

Intellij IDEA debugger not working on Gradle Vert.X project

ぐ巨炮叔叔 提交于 2019-12-30 03:28:05
问题 I'm developing a project using Vert.X framework using Gradle build tool. The problem I have is that breakpoints in IntelliJ simply doesn't work in any way I've tried. Here is a run configuration for Vert.X which I use in Gradle: run { args = [ 'run', mainVerticleName, "-conf", confPath, "--redeploy=$project.ext.watchForChange", "--launcher-class=$mainClassName", "--on-redeploy=$project.ext.doOnChange" ] } So the deployment is done using Gradle , runs without any issues, IntelliJ debugger is

Vertx scaling the number of instances per thread

你。 提交于 2019-12-30 02:29:08
问题 Vert.x is a tool-kit for building reactive applications on the JVM. I want to use vertx for JVM-based auto-scalable RESTful backend API. So far what I've found from the documentation, that it takes by default the number of cores in your machine, let's say you have N cores and creates N threads for each core, each thread is a event bus, each thread contains vertx instances. The question is, how does Vertx control the number of instances? based on load-pressure? This thing about control over

Pattern for using properly MongoClient in Vert.x

狂风中的少年 提交于 2019-12-25 03:37:21
问题 I feel quite uncomfortable with the MongoClient class, certainly because I don't exactly understand what it is and how it works. The first call to MongoClient.createShared will actually create the pool, and the specified config will be used. Subsequent calls will return a new client instance that uses the same pool, so the configuration won’t be used. Does that mean that the pattern should be: In startup function, to create the pool, we make a call mc = MongoClient.createShared(vx, config,

How to mock EntityBus.rxSend()

断了今生、忘了曾经 提交于 2019-12-25 00:05:52
问题 The io.vertx.reactivex.core.eventbus.EventBus.rxSend() method has the following signature: public <T> Single<Message<T>> rxSend(String address, Object message, DeliveryOptions options) What is the correct way to mock this so that it returns a Single containing a real object? The issue is that the Message class has no constructor apart from one which which takes another Message object. So the following will compile: Mockito.when(eventBus.rxSend(Mockito.isA(String.class), Mockito.isA(JsonObject

How to fail a java.util.concurrent.Future

坚强是说给别人听的谎言 提交于 2019-12-24 17:08:31
问题 There is pretty heavy use of io.vertx.core.Future in the vertx ecosystem: https://vertx.io/docs/apidocs/io/vertx/core/Future.html An example of using Vertx Future is here: private Future<Void> prepareDatabase() { Future<Void> future = Future.future(); dbClient = JDBCClient.createShared(vertx, new JsonObject(...)); dbClient.getConnection(ar -> { if (ar.failed()) { LOGGER.error("Could not open a database connection", ar.cause()); future.fail(ar.cause()); // here return; } SQLConnection

Worker verticles not processing requests in parallel

穿精又带淫゛_ 提交于 2019-12-24 00:22:44
问题 I am trying to scale an application which does a blocking call to an external application to fetch some data (Request and response order does not matter) Since, its a blocking call as described in the vertx docs I am using worker verticle with worker pool set to 5 and I have deployed 5 instances of the worker verticle When I submit multiple queries(when I tested I just fired 3 queries) even though my verticle is defined as worker with multiple instances with sufficient worker threads to

Verticles and uncaught exceptions

不问归期 提交于 2019-12-23 09:29:11
问题 Considering the scenario that one of the verticles throws an uncaught exception. What happens next? If the verticle state is removed from the system is there some mechanism similar to erlang supervisors to restart the verticle? Documentation is not very clear about this aspect. Update based on comments: What interest me the most is the situation when an exception is thrown from the processing handlers of a received message (through the bus) Regards 回答1: I have answered part of my own question

how to enable CORS with Vert.x 2.x

浪子不回头ぞ 提交于 2019-12-22 08:24:54
问题 I am trying to make cross-domain requests with Angularjs 1.4.5. But can't get success. I have configured $httpprovider .config(['$httpProvider', function($httpProvider) { $httpProvider.defaults.useXDomain = true; delete $httpProvider.defaults.headers.common['X-Requested-With']; $httpProvider.defaults.headers.common['Accept']= "application/json, text/plain, */*"; $httpProvider.defaults.headers.put["Content-Type"] = "application/x-www-form-urlencoded;charset=utf-8"; $httpProvider.defaults

vertx - reading from property/config file

流过昼夜 提交于 2019-12-22 06:56:02
问题 How to read data from property files? I understand vertx uses '.json' files for storing data but not sure how to create JsonObject from property/config file. I would like to keep, server port, connection url, db name etc. in to a config file. 回答1: you should run your verticle over io.vertx.core.Launcher , then you could add conf option -conf config.panser.json 回答2: Create the src/main/conf/my-application-conf.json with the following content: { "http.port" : 8082 } And now, to use this