vert.x

Json nested Objects check if null

≡放荡痞女 提交于 2019-12-11 09:22:27
问题 consider the following json { "sub1":{ "name":"Name-sub1", "sub11":{ "name":"Name-sub11", "sub111":{ "name":"Name-sub111", ... }, .. }, ... }, ... } I now want to fetch the inner name Element (Name-sub111) in java (it's a io.vertx.core.json.JsonObject) object.getJsonObject("sub1").getJsonObject("sub11").getJsonObject("sub111").getString("name") But I'm not sure if sub1 or sub11 or sub111 even exist - so I always need to check for null if(object.getJsonObject("sub1") != null && object

How vertx handlers work?

安稳与你 提交于 2019-12-11 09:18:43
问题 For the last week I read documentation about vertx. What i don't get it's how vertx handlers are work? For example public class Client extends AbstractVerticle{ @Override public void start() throws Exception { final HttpClient httpClient = this.vertx.createHttpClient(); this.vertx.setPeriodic(1000, handler->{ httpClient.getNow(8080, "localhost", "/", responseHandler -> { System.out.println("response"); }); }); } } And server is: public class JdbcVertx extends AbstractVerticle{ @Override

In Vert.x web client, can I map a JSON response to a collection of POJOs?

一个人想着一个人 提交于 2019-12-11 07:05:36
问题 In Vert.x Web client manual there's an example of decoding an incoming JSON response into a POJO: client .get(8080, "myserver.mycompany.com", "/some-uri") .as(BodyCodec.json(User.class)) .send(ar -> { // Process the response }) Is there a way to decode an incoming JSON array into a collection of objects? 回答1: I don't believe you can use a BodyCodec to convert the content straight to a collection of objects. However you use Vert.x core Json class with the body as Buffer client .get(8080,

How to enable auto redeploy in vertx when using intellij

╄→гoц情女王★ 提交于 2019-12-11 05:13:43
问题 How to enable auto redeploy in vertx application code when running in intellij idea? Intellij Settings for hot deployment of vertx application. 回答1: create a Run configuration (Application), set the Main class to io.vertx.core.Launcher. In the Program arguments write: run your-verticle-fully-qualified-name --redeploy=**/*.class --launcher-class=io.vertx.core.Launcher. To trigger the redeployment, you need to make the project or the module explicitly (Build menu → Make project). 来源: https:/

How to access gmail API?

倖福魔咒の 提交于 2019-12-11 03:30:02
问题 I generate my JWT, if my token is correct why dont work ? in Google Developers Console i enabled gmail plus youtube and other API, in credentials generate and download json { "private_key_id": "22dcf", "private_key": "-----BEGIN PRIVATE KEY-----(remove)-----END PRIVATE KEY-----\n", "client_email": "vgfjjc6@developer.gserviceaccount.com", "client_id": "jc6.apps.googleusercontent.com", "type": "service_account" } first generate token var sHead=JSON.stringify({"alg":"RS256","typ":"JWT"}); var

How to use vert.x-rx to create reactive client-server TCP communication

前提是你 提交于 2019-12-11 03:26:17
问题 I'm currently working on a project which requires TCP communication between an external system and an application which I will write (in Java). As we all know, this can easily be achieved using regular NIO. However, as part of this new project I'm working on, I have to use Vert.x to provide the TCP communication. Please refer to the image below: On the right, I have my application which runs as a TCP server waiting for a connection from the external system, on the left. I've read that to

How to register a SPI implementation when running exec:java

亡梦爱人 提交于 2019-12-11 00:51:20
问题 I'm trying to make VertX Mertrics work when running via the exec:java Maven plugin. All works as expected when I package the application into a fatjar and run it with java -jar fat.jar -conf config.json -Dvertx.metrics.options.enabled=true When I run it with mvn clean package exec:java -DskipTests I see: 2016-03-22 18:39:58.833 WARN i.v.c.i.VertxImpl:348 - Metrics has been set to enabled but no VertxMetricsFactory found on classpath I tried several approaches: adding io.vertx:vertx-dropwizard

List all registered routes in Vertx

情到浓时终转凉″ 提交于 2019-12-10 21:26:01
问题 Is there any way (like in a symfony application) to list down all the available/register routes on a vertx server? I am facing an issue that my registered route is returning a 404 on running restassure tests. 回答1: Yes, but you have to write a bit of code to achieve that. // Example router setup Router router = Router.router(vertx); router.route(HttpMethod.GET, "/").handler(routingContext -> { routingContext.response().end("Root"); }); router.route(HttpMethod.GET, "/users").handler

Vertx FileUpload uploads file without extension

二次信任 提交于 2019-12-10 20:13:00
问题 I am using vertx-web and trying to upload file. Here is my code: router.route().handler(BodyHandler.create().setUploadsDirectory("some/path/uploads")); router.post("/api/upload").handler(routingContext -> { for(FileUpload f : routingContext.fileUploads()){ System.out.println(f.fileName()); // logo.png } routingContext.response().end() }); Above code, uploads file to the given path, but the uploaded file extension is missing. File upload name: logo.png File saved name: 45edd7b4-5287-4fba-927e

Vertx Webroot In Fat Jar

╄→гoц情女王★ 提交于 2019-12-10 12:13:37
问题 I am building a fat jar for a Vertx-Web application. I would like to serve some static files. I packaged the jar file, with webroot folder. See below screenshot for my jar structure: I was able to load the webroot/static/test.html file by doing: routingContext.response().sendFile("webroot/static/test.html"); However, I am not able to get the static handler to work. Below is my full code: package com.jdescript; import java.io.BufferedReader; import java.io.IOException; import java.io