vert.x

How to run infinite loop on vertx using while() loop

别等时光非礼了梦想. 提交于 2019-12-13 01:04:51
问题 I would like to run an infinite loop on verx on diff thread. Should be something like this: vertx.executeBlocking(future -> { while(true){ } //some logic (e.g waiting on blocking-code) } thing is that on vertx even for executeBlocking threads you have global timeout which you can increase. but I would like to set for this execution non-timeout warnings as it will run forever am I achieving my purpose right with vertx? In case 1 is true. how to exclude this specific blocking execution from the

IntelliJ and Vertx: How to run org.vertx.java.deploy.impl.cli.Starter ?

拈花ヽ惹草 提交于 2019-12-12 05:48:43
问题 I have the following code inside Maven project: package hello; import org.vertx.java.core.Handler; import org.vertx.java.core.http.HttpServerRequest; import org.vertx.java.deploy.Verticle; public class Server extends Verticle { public void start() { vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>() { @Override public void handle(HttpServerRequest req) { System.out.println("Got request: " + req.uri); System.out.println("Headers are: "); for (String key : req.headers()

Spring Boot webapp with embedded vertx fails to start

不问归期 提交于 2019-12-12 02:45:46
问题 I am trying to start a Spring Boot webapp(executable war) with embedded clustered vertx. It fails with below exception. java.lang.IllegalArgumentException: PortableFactory[-14] is already registered! com.hazelcast.concurrent.countdownlatch.client.CountDownLatchPortableHook$1@738ae532 -> com.hazelcast.concurrent.countdownlatch.client.CountDownLatchPortableHook$1@60d09d45 at com.hazelcast.nio.serialization.PortableHookLoader.register(PortableHookLoader.java:84) at com.hazelcast.nio

vertx clustered mode hazelcast log config on linux

会有一股神秘感。 提交于 2019-12-11 20:14:24
问题 Using Eclipse on Windows, a vertx Verticle with a misconfigured cluster.xml shows the following error in the Eclipse console: 11:46:18.536 [hz._hzInstance_1_dev.generic-operation.thread-0] ERROR com.hazelcast.cluster - [192.168.25.8]:5701 [dev] [3.5.2] Node could not join cluster. A Configuration mismatch was detected: Incompatible joiners! expected: multicast, found: tcp-ip Node is going to shutdown now! 11:46:22.529 [vert.x-worker-thread-0] ERROR com.hazelcast.cluster.impl.TcpIpJoiner -

Vert.x Reactive Kafka client: chaining not working when writing?

℡╲_俬逩灬. 提交于 2019-12-11 18:07:16
问题 I am using io.vertx.reactivex.kafka.client.producer.KafkaProducer client. The client has a rxWrite function which returns Single<RecordMetadata> . However I need to log error if any, during write operation. It apparently is not getting executed. I have written following working example. test(): Function to test the chaining and logging fun test(): Single<Int> { val data = Single.just(ArrayList<String>().apply { add("Hello") add("World") }) data.flattenAsObservable<String> { list -> list }

Caching layer for different microservices

怎甘沉沦 提交于 2019-12-11 17:24:02
问题 We have different microservices which makes duplicate calls to internal and external services. We need to cache these calls between services to improve latency. We are thinking of introducing an API gateway whose major aim would be caching the data between services. Some other objectives are - i) Would be calling different micro-services to aggregate their response. ii) Would also be avoiding multiple calls to external services across micro services. iii) Would be taking care of cache miss &

How to properly handle exceptions in MongoClient for VertX

走远了吗. 提交于 2019-12-11 17:19:54
问题 In the startup method of my application I want to check that the credentials for MongoDB provided to the application are OK. If they are OK, I continue the startup, if not, the application is supposed to exit as it cannot connect to the DB. The code snippet is as below: // Create the client MongoClient mongodb = null; try { mongodb = MongoClient.createShared(vertx, mongo_cnf, mongo_cnf.getString("pool_name")); } catch(Exception e) { log.error("Unable to create MongoDB client. Cause: '{}'.

Vert.x系列(五)--ContextImpl源码分析

…衆ロ難τιáo~ 提交于 2019-12-11 16:50:35
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 前言: 线程安全是Vert.x的重要特性,但这一特性是由它依赖的netty实现的,Vert.x只是直接拿过来使用。 这里涉及到很多个类。 ContextImpl、EventLoopContext、NioEventLoop、和NioEventLoop的父类SingleThreadEventLoop、和NioEventLoop的爷爷类SingleThreadEventExecutor。 原理: Netty定义了EventExecutor事件执行器,用做对任务处理的封装。执行器内部维护了Queue<Runable> ,实现了任务的顺序执行。还定义了MultithreadEventExecutorGroup类,维护数组变量EventExecutor[] children,实现了多核CPU的利用; (数组队列结构,非常像Hashmap的数组链表结构)。一个Verticle和一个ContextImpl对应,再有一个ContextImpl和一个EventExecutor对应,使所有对Verticle的操作都在一个Queue<Runable>中依次执行,实现了线程安全。 代码: 代码1.构造器 对于占了大部分的普通Verticle来说一般来说,会依次由VertxImpl.getOrCreateContext()

How to use eventbus messaging in vertx?

怎甘沉沦 提交于 2019-12-11 16:19:33
问题 I followed the instructions in sample and ran: vertx run eventbus_pointtopoint/receiver.rb -cluster vertx run eventbus_pointtopoint/sender.rb -cluster Then I only got: ➜ ruby vertx run eventbus_pointtopoint/receiver.rb -cluster Starting clustering... No cluster-host specified so using address 192.168.56.1 Succeeded in deploying verticle ➜ ruby vertx run eventbus_pointtopoint/sender.rb -cluster Starting clustering... No cluster-host specified so using address 192.168.56.1 Succeeded in

Vertx - using the Router failureHandler for the errors in async calls

好久不见. 提交于 2019-12-11 15:18:22
问题 We have recently discovered the failureHandler in the Vertx router We thought it could help us get rid of all the repetitive try-catch blocks we have. But alas, it seems that the exceptions that are thrown inside the callbacks are not caught by the failureHandler . Example: below, the failureHandler is called only for the 3rd case: // Get the user details router.get("/user").handler(ctx -> { ctx.response().headers().add("content-type", "application/json"); // some async operation userApiImpl