/*
 * Copyright 2014 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.vertx.reactivex.core;

import java.util.Map;
import io.reactivex.Observable;
import io.reactivex.Flowable;
import io.reactivex.Single;
import io.reactivex.Completable;
import io.reactivex.Maybe;
import io.vertx.core.spi.VerticleFactory;
import io.vertx.core.dns.DnsClientOptions;
import java.util.function.Supplier;
import io.vertx.core.AsyncResult;
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.datagram.DatagramSocketOptions;
import io.netty.channel.EventLoopGroup;
import io.vertx.core.VertxOptions;
import java.util.Set;
import io.vertx.core.Verticle;
import io.vertx.core.net.NetClientOptions;
import java.util.concurrent.TimeUnit;
import io.vertx.core.net.NetServerOptions;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.http.HttpServerOptions;
import io.vertx.core.Handler;

The entry point into the Vert.x Core API.

You use an instance of this class for functionality including:

  • Creating TCP clients and servers
  • Creating HTTP clients and servers
  • Creating DNS clients
  • Creating Datagram sockets
  • Setting and cancelling periodic and one-shot timers
  • Getting a reference to the event bus API
  • Getting a reference to the file system API
  • Getting a reference to the shared data API
  • Deploying and undeploying verticles

Most functionality in Vert.x core is fairly low level.

To create an instance of this class you can use the static factory methods: vertx, vertx and clusteredVertx.

Please see the user manual for more detailed usage information.

NOTE: This class has been automatically generated from the original non RX-ified interface using Vert.x codegen.
/** * The entry point into the Vert.x Core API. * <p> * You use an instance of this class for functionality including: * <ul> * <li>Creating TCP clients and servers</li> * <li>Creating HTTP clients and servers</li> * <li>Creating DNS clients</li> * <li>Creating Datagram sockets</li> * <li>Setting and cancelling periodic and one-shot timers</li> * <li>Getting a reference to the event bus API</li> * <li>Getting a reference to the file system API</li> * <li>Getting a reference to the shared data API</li> * <li>Deploying and undeploying verticles</li> * </ul> * <p> * Most functionality in Vert.x core is fairly low level. * <p> * To create an instance of this class you can use the static factory methods: {@link io.vertx.reactivex.core.Vertx#vertx}, * {@link io.vertx.reactivex.core.Vertx#vertx} and {@link io.vertx.reactivex.core.Vertx#clusteredVertx}. * <p> * Please see the user manual for more detailed usage information. * * <p/> * NOTE: This class has been automatically generated from the {@link io.vertx.core.Vertx original} non RX-ified interface using Vert.x codegen. */
@io.vertx.lang.rx.RxGen(io.vertx.core.Vertx.class) public class Vertx implements io.vertx.reactivex.core.metrics.Measured { @Override public String toString() { return delegate.toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Vertx that = (Vertx) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final io.vertx.lang.rx.TypeArg<Vertx> __TYPE_ARG = new io.vertx.lang.rx.TypeArg<>( obj -> new Vertx((io.vertx.core.Vertx) obj), Vertx::getDelegate ); private final io.vertx.core.Vertx delegate; public Vertx(io.vertx.core.Vertx delegate) { this.delegate = delegate; } public io.vertx.core.Vertx getDelegate() { return delegate; }
Whether the metrics are enabled for this measured object
Returns:true if metrics are enabled
/** * Whether the metrics are enabled for this measured object * @return <code>true</code> if metrics are enabled */
public boolean isMetricsEnabled() { boolean ret = delegate.isMetricsEnabled(); return ret; }
Creates a non clustered instance using default options.
Returns:the instance
/** * Creates a non clustered instance using default options. * @return the instance */
public static io.vertx.reactivex.core.Vertx vertx() { io.vertx.reactivex.core.Vertx ret = io.vertx.reactivex.core.Vertx.newInstance(io.vertx.core.Vertx.vertx()); return ret; }
Creates a non clustered instance using the specified options
Params:
  • options – the options to use
Returns:the instance
/** * Creates a non clustered instance using the specified options * @param options the options to use * @return the instance */
public static io.vertx.reactivex.core.Vertx vertx(VertxOptions options) { io.vertx.reactivex.core.Vertx ret = io.vertx.reactivex.core.Vertx.newInstance(io.vertx.core.Vertx.vertx(options)); return ret; }
Creates a clustered instance using the specified options.

The instance is created asynchronously and the resultHandler is called with the result when it is ready.

Params:
  • options – the options to use
  • resultHandler – the result handler that will receive the result
/** * Creates a clustered instance using the specified options. * <p> * The instance is created asynchronously and the resultHandler is called with the result when it is ready. * @param options the options to use * @param resultHandler the result handler that will receive the result */
public static void clusteredVertx(VertxOptions options, Handler<AsyncResult<io.vertx.reactivex.core.Vertx>> resultHandler) { io.vertx.core.Vertx.clusteredVertx(options, new Handler<AsyncResult<io.vertx.core.Vertx>>() { public void handle(AsyncResult<io.vertx.core.Vertx> ar) { if (ar.succeeded()) { resultHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.core.Vertx.newInstance(ar.result()))); } else { resultHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
Creates a clustered instance using the specified options.

The instance is created asynchronously and the resultHandler is called with the result when it is ready.

Params:
  • options – the options to use
Returns:
/** * Creates a clustered instance using the specified options. * <p> * The instance is created asynchronously and the resultHandler is called with the result when it is ready. * @param options the options to use * @return */
public static Single<io.vertx.reactivex.core.Vertx> rxClusteredVertx(VertxOptions options) { return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> { clusteredVertx(options, handler); }); }
Gets the current context
Returns:The current context or null if no current context
/** * Gets the current context * @return The current context or null if no current context */
public static io.vertx.reactivex.core.Context currentContext() { io.vertx.reactivex.core.Context ret = io.vertx.reactivex.core.Context.newInstance(io.vertx.core.Vertx.currentContext()); return ret; }
Gets the current context, or creates one if there isn't one
Returns:The current context (created if didn't exist)
/** * Gets the current context, or creates one if there isn't one * @return The current context (created if didn't exist) */
public io.vertx.reactivex.core.Context getOrCreateContext() { io.vertx.reactivex.core.Context ret = io.vertx.reactivex.core.Context.newInstance(delegate.getOrCreateContext()); return ret; }
Create a TCP/SSL server using the specified options
Params:
  • options – the options to use
Returns:the server
/** * Create a TCP/SSL server using the specified options * @param options the options to use * @return the server */
public io.vertx.reactivex.core.net.NetServer createNetServer(NetServerOptions options) { io.vertx.reactivex.core.net.NetServer ret = io.vertx.reactivex.core.net.NetServer.newInstance(delegate.createNetServer(options)); return ret; }
Create a TCP/SSL server using default options
Returns:the server
/** * Create a TCP/SSL server using default options * @return the server */
public io.vertx.reactivex.core.net.NetServer createNetServer() { io.vertx.reactivex.core.net.NetServer ret = io.vertx.reactivex.core.net.NetServer.newInstance(delegate.createNetServer()); return ret; }
Create a TCP/SSL client using the specified options
Params:
  • options – the options to use
Returns:the client
/** * Create a TCP/SSL client using the specified options * @param options the options to use * @return the client */
public io.vertx.reactivex.core.net.NetClient createNetClient(NetClientOptions options) { io.vertx.reactivex.core.net.NetClient ret = io.vertx.reactivex.core.net.NetClient.newInstance(delegate.createNetClient(options)); return ret; }
Create a TCP/SSL client using default options
Returns:the client
/** * Create a TCP/SSL client using default options * @return the client */
public io.vertx.reactivex.core.net.NetClient createNetClient() { io.vertx.reactivex.core.net.NetClient ret = io.vertx.reactivex.core.net.NetClient.newInstance(delegate.createNetClient()); return ret; }
Create an HTTP/HTTPS server using the specified options
Params:
  • options – the options to use
Returns:the server
/** * Create an HTTP/HTTPS server using the specified options * @param options the options to use * @return the server */
public io.vertx.reactivex.core.http.HttpServer createHttpServer(HttpServerOptions options) { io.vertx.reactivex.core.http.HttpServer ret = io.vertx.reactivex.core.http.HttpServer.newInstance(delegate.createHttpServer(options)); return ret; }
Create an HTTP/HTTPS server using default options
Returns:the server
/** * Create an HTTP/HTTPS server using default options * @return the server */
public io.vertx.reactivex.core.http.HttpServer createHttpServer() { io.vertx.reactivex.core.http.HttpServer ret = io.vertx.reactivex.core.http.HttpServer.newInstance(delegate.createHttpServer()); return ret; }
Create a HTTP/HTTPS client using the specified options
Params:
  • options – the options to use
Returns:the client
/** * Create a HTTP/HTTPS client using the specified options * @param options the options to use * @return the client */
public io.vertx.reactivex.core.http.HttpClient createHttpClient(HttpClientOptions options) { io.vertx.reactivex.core.http.HttpClient ret = io.vertx.reactivex.core.http.HttpClient.newInstance(delegate.createHttpClient(options)); return ret; }
Create a HTTP/HTTPS client using default options
Returns:the client
/** * Create a HTTP/HTTPS client using default options * @return the client */
public io.vertx.reactivex.core.http.HttpClient createHttpClient() { io.vertx.reactivex.core.http.HttpClient ret = io.vertx.reactivex.core.http.HttpClient.newInstance(delegate.createHttpClient()); return ret; }
Create a datagram socket using the specified options
Params:
  • options – the options to use
Returns:the socket
/** * Create a datagram socket using the specified options * @param options the options to use * @return the socket */
public io.vertx.reactivex.core.datagram.DatagramSocket createDatagramSocket(DatagramSocketOptions options) { io.vertx.reactivex.core.datagram.DatagramSocket ret = io.vertx.reactivex.core.datagram.DatagramSocket.newInstance(delegate.createDatagramSocket(options)); return ret; }
Create a datagram socket using default options
Returns:the socket
/** * Create a datagram socket using default options * @return the socket */
public io.vertx.reactivex.core.datagram.DatagramSocket createDatagramSocket() { io.vertx.reactivex.core.datagram.DatagramSocket ret = io.vertx.reactivex.core.datagram.DatagramSocket.newInstance(delegate.createDatagramSocket()); return ret; }
Get the filesystem object. There is a single instance of FileSystem per Vertx instance.
Returns:the filesystem object
/** * Get the filesystem object. There is a single instance of FileSystem per Vertx instance. * @return the filesystem object */
public io.vertx.reactivex.core.file.FileSystem fileSystem() { if (cached_0 != null) { return cached_0; } io.vertx.reactivex.core.file.FileSystem ret = io.vertx.reactivex.core.file.FileSystem.newInstance(delegate.fileSystem()); cached_0 = ret; return ret; }
Get the event bus object. There is a single instance of EventBus per Vertx instance.
Returns:the event bus object
/** * Get the event bus object. There is a single instance of EventBus per Vertx instance. * @return the event bus object */
public io.vertx.reactivex.core.eventbus.EventBus eventBus() { if (cached_1 != null) { return cached_1; } io.vertx.reactivex.core.eventbus.EventBus ret = io.vertx.reactivex.core.eventbus.EventBus.newInstance(delegate.eventBus()); cached_1 = ret; return ret; }
Create a DNS client to connect to a DNS server at the specified host and port, with the default query timeout (5 seconds)

Params:
  • port – the port
  • host – the host
Returns:the DNS client
/** * Create a DNS client to connect to a DNS server at the specified host and port, with the default query timeout (5 seconds) * <p/> * @param port the port * @param host the host * @return the DNS client */
public io.vertx.reactivex.core.dns.DnsClient createDnsClient(int port, String host) { io.vertx.reactivex.core.dns.DnsClient ret = io.vertx.reactivex.core.dns.DnsClient.newInstance(delegate.createDnsClient(port, host)); return ret; }
Create a DNS client to connect to the DNS server configured by VertxOptions

DNS client takes the first configured resolver address provided by }

Returns:the DNS client
/** * Create a DNS client to connect to the DNS server configured by {@link io.vertx.core.VertxOptions} * <p> * DNS client takes the first configured resolver address provided by } * @return the DNS client */
public io.vertx.reactivex.core.dns.DnsClient createDnsClient() { io.vertx.reactivex.core.dns.DnsClient ret = io.vertx.reactivex.core.dns.DnsClient.newInstance(delegate.createDnsClient()); return ret; }
Create a DNS client to connect to a DNS server
Params:
  • options – the client options
Returns:the DNS client
/** * Create a DNS client to connect to a DNS server * @param options the client options * @return the DNS client */
public io.vertx.reactivex.core.dns.DnsClient createDnsClient(DnsClientOptions options) { io.vertx.reactivex.core.dns.DnsClient ret = io.vertx.reactivex.core.dns.DnsClient.newInstance(delegate.createDnsClient(options)); return ret; }
Get the shared data object. There is a single instance of SharedData per Vertx instance.
Returns:the shared data object
/** * Get the shared data object. There is a single instance of SharedData per Vertx instance. * @return the shared data object */
public io.vertx.reactivex.core.shareddata.SharedData sharedData() { if (cached_2 != null) { return cached_2; } io.vertx.reactivex.core.shareddata.SharedData ret = io.vertx.reactivex.core.shareddata.SharedData.newInstance(delegate.sharedData()); cached_2 = ret; return ret; }
Set a one-shot timer to fire after delay milliseconds, at which point handler will be called with the id of the timer.
Params:
  • delay – the delay in milliseconds, after which the timer will fire
  • handler – the handler that will be called with the timer ID when the timer fires
Returns:the unique ID of the timer
/** * Set a one-shot timer to fire after <code>delay</code> milliseconds, at which point <code>handler</code> will be called with * the id of the timer. * @param delay the delay in milliseconds, after which the timer will fire * @param handler the handler that will be called with the timer ID when the timer fires * @return the unique ID of the timer */
public long setTimer(long delay, Handler<Long> handler) { long ret = delegate.setTimer(delay, handler); return ret; }
Returns a one-shot timer as a read stream. The timer will be fired after delay milliseconds after the has been called.
Params:
  • delay – the delay in milliseconds, after which the timer will fire
Returns:the timer stream
/** * Returns a one-shot timer as a read stream. The timer will be fired after <code>delay</code> milliseconds after * the has been called. * @param delay the delay in milliseconds, after which the timer will fire * @return the timer stream */
public io.vertx.reactivex.core.TimeoutStream timerStream(long delay) { io.vertx.reactivex.core.TimeoutStream ret = io.vertx.reactivex.core.TimeoutStream.newInstance(delegate.timerStream(delay)); return ret; }
Set a periodic timer to fire every delay milliseconds, at which point handler will be called with the id of the timer.
Params:
  • delay – the delay in milliseconds, after which the timer will fire
  • handler – the handler that will be called with the timer ID when the timer fires
Returns:the unique ID of the timer
/** * Set a periodic timer to fire every <code>delay</code> milliseconds, at which point <code>handler</code> will be called with * the id of the timer. * @param delay the delay in milliseconds, after which the timer will fire * @param handler the handler that will be called with the timer ID when the timer fires * @return the unique ID of the timer */
public long setPeriodic(long delay, Handler<Long> handler) { long ret = delegate.setPeriodic(delay, handler); return ret; }
Returns a periodic timer as a read stream. The timer will be fired every delay milliseconds after the has been called.
Params:
  • delay – the delay in milliseconds, after which the timer will fire
Returns:the periodic stream
/** * Returns a periodic timer as a read stream. The timer will be fired every <code>delay</code> milliseconds after * the has been called. * @param delay the delay in milliseconds, after which the timer will fire * @return the periodic stream */
public io.vertx.reactivex.core.TimeoutStream periodicStream(long delay) { io.vertx.reactivex.core.TimeoutStream ret = io.vertx.reactivex.core.TimeoutStream.newInstance(delegate.periodicStream(delay)); return ret; }
Cancels the timer with the specified id.
Params:
  • id – The id of the timer to cancel
Returns:true if the timer was successfully cancelled, or false if the timer does not exist.
/** * Cancels the timer with the specified <code>id</code>. * @param id The id of the timer to cancel * @return true if the timer was successfully cancelled, or false if the timer does not exist. */
public boolean cancelTimer(long id) { boolean ret = delegate.cancelTimer(id); return ret; }
Puts the handler on the event queue for the current context so it will be run asynchronously ASAP after all preceeding events have been handled.
Params:
  • action – - a handler representing the action to execute
/** * Puts the handler on the event queue for the current context so it will be run asynchronously ASAP after all * preceeding events have been handled. * @param action - a handler representing the action to execute */
public void runOnContext(Handler<Void> action) { delegate.runOnContext(action); }
Stop the the Vertx instance and release any resources held by it.

The instance cannot be used after it has been closed.

The actual close is asynchronous and may not complete until after the call has returned.

/** * Stop the the Vertx instance and release any resources held by it. * <p> * The instance cannot be used after it has been closed. * <p> * The actual close is asynchronous and may not complete until after the call has returned. */
public void close() { delegate.close(); }
Like close but the completionHandler will be called when the close is complete
Params:
  • completionHandler – The handler will be notified when the close is complete.
/** * Like {@link io.vertx.reactivex.core.Vertx#close} but the completionHandler will be called when the close is complete * @param completionHandler The handler will be notified when the close is complete. */
public void close(Handler<AsyncResult<Void>> completionHandler) { delegate.close(completionHandler); }
Like close but the completionHandler will be called when the close is complete
Returns:
/** * Like {@link io.vertx.reactivex.core.Vertx#close} but the completionHandler will be called when the close is complete * @return */
public Completable rxClose() { return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> { close(handler); }); }
Deploy a verticle instance given a name.

Given the name, Vert.x selects a instance to use to instantiate the verticle.

For the rules on how factories are selected please consult the user manual.

Params:
  • name – the name.
/** * Deploy a verticle instance given a name. * <p> * Given the name, Vert.x selects a instance to use to instantiate the verticle. * <p> * For the rules on how factories are selected please consult the user manual. * @param name the name. */
public void deployVerticle(String name) { delegate.deployVerticle(name); }
Like deployVerticle but the completionHandler will be notified when the deployment is complete.

If the deployment is successful the result will contain a String representing the unique deployment ID of the deployment.

This deployment ID can subsequently be used to undeploy the verticle.

Params:
  • name – The identifier
  • completionHandler – a handler which will be notified when the deployment is complete
/** * Like {@link io.vertx.reactivex.core.Vertx#deployVerticle} but the completionHandler will be notified when the deployment is complete. * <p> * If the deployment is successful the result will contain a String representing the unique deployment ID of the * deployment. * <p> * This deployment ID can subsequently be used to undeploy the verticle. * @param name The identifier * @param completionHandler a handler which will be notified when the deployment is complete */
public void deployVerticle(String name, Handler<AsyncResult<String>> completionHandler) { delegate.deployVerticle(name, completionHandler); }
Like deployVerticle but the completionHandler will be notified when the deployment is complete.

If the deployment is successful the result will contain a String representing the unique deployment ID of the deployment.

This deployment ID can subsequently be used to undeploy the verticle.

Params:
  • name – The identifier
Returns:
/** * Like {@link io.vertx.reactivex.core.Vertx#deployVerticle} but the completionHandler will be notified when the deployment is complete. * <p> * If the deployment is successful the result will contain a String representing the unique deployment ID of the * deployment. * <p> * This deployment ID can subsequently be used to undeploy the verticle. * @param name The identifier * @return */
public Single<String> rxDeployVerticle(String name) { return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> { deployVerticle(name, handler); }); }
Like deployVerticle but DeploymentOptions are provided to configure the deployment.
Params:
  • name – the name
  • options – the deployment options.
/** * Like {@link io.vertx.reactivex.core.Vertx#deployVerticle} but {@link io.vertx.core.DeploymentOptions} are provided to configure the * deployment. * @param name the name * @param options the deployment options. */
public void deployVerticle(String name, DeploymentOptions options) { delegate.deployVerticle(name, options); }
Like deployVerticle but DeploymentOptions are provided to configure the deployment.
Params:
  • name – the name
  • options – the deployment options.
  • completionHandler – a handler which will be notified when the deployment is complete
/** * Like {@link io.vertx.reactivex.core.Vertx#deployVerticle} but {@link io.vertx.core.DeploymentOptions} are provided to configure the * deployment. * @param name the name * @param options the deployment options. * @param completionHandler a handler which will be notified when the deployment is complete */
public void deployVerticle(String name, DeploymentOptions options, Handler<AsyncResult<String>> completionHandler) { delegate.deployVerticle(name, options, completionHandler); }
Like deployVerticle but DeploymentOptions are provided to configure the deployment.
Params:
  • name – the name
  • options – the deployment options.
Returns:
/** * Like {@link io.vertx.reactivex.core.Vertx#deployVerticle} but {@link io.vertx.core.DeploymentOptions} are provided to configure the * deployment. * @param name the name * @param options the deployment options. * @return */
public Single<String> rxDeployVerticle(String name, DeploymentOptions options) { return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> { deployVerticle(name, options, handler); }); }
Undeploy a verticle deployment.

The actual undeployment happens asynchronously and may not complete until after the method has returned.

Params:
  • deploymentID – the deployment ID
/** * Undeploy a verticle deployment. * <p> * The actual undeployment happens asynchronously and may not complete until after the method has returned. * @param deploymentID the deployment ID */
public void undeploy(String deploymentID) { delegate.undeploy(deploymentID); }
Like undeploy(String) but the completionHandler will be notified when the undeployment is complete.
Params:
  • deploymentID – the deployment ID
  • completionHandler – a handler which will be notified when the undeployment is complete
/** * Like {@link io.vertx.reactivex.core.Vertx #undeploy(String)} but the completionHandler will be notified when the undeployment is complete. * @param deploymentID the deployment ID * @param completionHandler a handler which will be notified when the undeployment is complete */
public void undeploy(String deploymentID, Handler<AsyncResult<Void>> completionHandler) { delegate.undeploy(deploymentID, completionHandler); }
Like undeploy(String) but the completionHandler will be notified when the undeployment is complete.
Params:
  • deploymentID – the deployment ID
Returns:
/** * Like {@link io.vertx.reactivex.core.Vertx #undeploy(String)} but the completionHandler will be notified when the undeployment is complete. * @param deploymentID the deployment ID * @return */
public Completable rxUndeploy(String deploymentID) { return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> { undeploy(deploymentID, handler); }); }
Return a Set of deployment IDs for the currently deployed deploymentIDs.
Returns:Set of deployment IDs
/** * Return a Set of deployment IDs for the currently deployed deploymentIDs. * @return Set of deployment IDs */
public Set<String> deploymentIDs() { Set<String> ret = delegate.deploymentIDs(); return ret; }
Is this Vert.x instance clustered?
Returns:true if clustered
/** * Is this Vert.x instance clustered? * @return true if clustered */
public boolean isClustered() { boolean ret = delegate.isClustered(); return ret; }
Safely execute some blocking code.

Executes the blocking code in the handler blockingCodeHandler using a thread from the worker pool.

When the code is complete the handler resultHandler will be called with the result on the original context (e.g. on the original event loop of the caller).

A Future instance is passed into blockingCodeHandler. When the blocking code successfully completes, the handler should call the Promise.complete or Promise.complete method, or the Promise.fail method if it failed.

In the blockingCodeHandler the current context remains the original context and therefore any task scheduled in the blockingCodeHandler will be executed on the this context and not on the worker thread.

The blocking code should block for a reasonable amount of time (i.e no more than a few seconds). Long blocking operations or polling operations (i.e a thread that spin in a loop polling events in a blocking fashion) are precluded.

When the blocking operation lasts more than the 10 seconds, a message will be printed on the console by the blocked thread checker.

Long blocking operations should use a dedicated thread managed by the application, which can interact with verticles using the event-bus or Context.runOnContext

Params:
  • blockingCodeHandler – handler representing the blocking code to run
  • ordered – if true then if executeBlocking is called several times on the same context, the executions for that context will be executed serially, not in parallel. if false then they will be no ordering guarantees
  • resultHandler – handler that will be called when the blocking code is complete
/** * Safely execute some blocking code. * <p> * Executes the blocking code in the handler <code>blockingCodeHandler</code> using a thread from the worker pool. * <p> * When the code is complete the handler <code>resultHandler</code> will be called with the result on the original context * (e.g. on the original event loop of the caller). * <p> * A <code>Future</code> instance is passed into <code>blockingCodeHandler</code>. When the blocking code successfully completes, * the handler should call the {@link io.vertx.reactivex.core.Promise#complete} or {@link io.vertx.reactivex.core.Promise#complete} method, or the {@link io.vertx.reactivex.core.Promise#fail} * method if it failed. * <p> * In the <code>blockingCodeHandler</code> the current context remains the original context and therefore any task * scheduled in the <code>blockingCodeHandler</code> will be executed on the this context and not on the worker thread. * <p> * The blocking code should block for a reasonable amount of time (i.e no more than a few seconds). Long blocking operations * or polling operations (i.e a thread that spin in a loop polling events in a blocking fashion) are precluded. * <p> * When the blocking operation lasts more than the 10 seconds, a message will be printed on the console by the * blocked thread checker. * <p> * Long blocking operations should use a dedicated thread managed by the application, which can interact with * verticles using the event-bus or {@link io.vertx.reactivex.core.Context#runOnContext} * @param blockingCodeHandler handler representing the blocking code to run * @param ordered if true then if executeBlocking is called several times on the same context, the executions for that context will be executed serially, not in parallel. if false then they will be no ordering guarantees * @param resultHandler handler that will be called when the blocking code is complete */
public <T> void executeBlocking(Handler<io.vertx.reactivex.core.Promise<T>> blockingCodeHandler, boolean ordered, Handler<AsyncResult<T>> resultHandler) { delegate.executeBlocking(new Handler<io.vertx.core.Promise<T>>() { public void handle(io.vertx.core.Promise<T> event) { blockingCodeHandler.handle(io.vertx.reactivex.core.Promise.newInstance(event, io.vertx.lang.rx.TypeArg.unknown())); } }, ordered, resultHandler); }
Safely execute some blocking code.

Executes the blocking code in the handler blockingCodeHandler using a thread from the worker pool.

When the code is complete the handler resultHandler will be called with the result on the original context (e.g. on the original event loop of the caller).

A Future instance is passed into blockingCodeHandler. When the blocking code successfully completes, the handler should call the Promise.complete or Promise.complete method, or the Promise.fail method if it failed.

In the blockingCodeHandler the current context remains the original context and therefore any task scheduled in the blockingCodeHandler will be executed on the this context and not on the worker thread.

The blocking code should block for a reasonable amount of time (i.e no more than a few seconds). Long blocking operations or polling operations (i.e a thread that spin in a loop polling events in a blocking fashion) are precluded.

When the blocking operation lasts more than the 10 seconds, a message will be printed on the console by the blocked thread checker.

Long blocking operations should use a dedicated thread managed by the application, which can interact with verticles using the event-bus or Context.runOnContext

Params:
  • blockingCodeHandler – handler representing the blocking code to run
  • ordered – if true then if executeBlocking is called several times on the same context, the executions for that context will be executed serially, not in parallel. if false then they will be no ordering guarantees
Returns:
/** * Safely execute some blocking code. * <p> * Executes the blocking code in the handler <code>blockingCodeHandler</code> using a thread from the worker pool. * <p> * When the code is complete the handler <code>resultHandler</code> will be called with the result on the original context * (e.g. on the original event loop of the caller). * <p> * A <code>Future</code> instance is passed into <code>blockingCodeHandler</code>. When the blocking code successfully completes, * the handler should call the {@link io.vertx.reactivex.core.Promise#complete} or {@link io.vertx.reactivex.core.Promise#complete} method, or the {@link io.vertx.reactivex.core.Promise#fail} * method if it failed. * <p> * In the <code>blockingCodeHandler</code> the current context remains the original context and therefore any task * scheduled in the <code>blockingCodeHandler</code> will be executed on the this context and not on the worker thread. * <p> * The blocking code should block for a reasonable amount of time (i.e no more than a few seconds). Long blocking operations * or polling operations (i.e a thread that spin in a loop polling events in a blocking fashion) are precluded. * <p> * When the blocking operation lasts more than the 10 seconds, a message will be printed on the console by the * blocked thread checker. * <p> * Long blocking operations should use a dedicated thread managed by the application, which can interact with * verticles using the event-bus or {@link io.vertx.reactivex.core.Context#runOnContext} * @param blockingCodeHandler handler representing the blocking code to run * @param ordered if true then if executeBlocking is called several times on the same context, the executions for that context will be executed serially, not in parallel. if false then they will be no ordering guarantees * @return */
public <T> Maybe<T> rxExecuteBlocking(Handler<io.vertx.reactivex.core.Promise<T>> blockingCodeHandler, boolean ordered) { return io.vertx.reactivex.impl.AsyncResultMaybe.toMaybe(handler -> { executeBlocking(blockingCodeHandler, ordered, handler); }); }
Like executeBlocking called with ordered = true.
Params:
  • blockingCodeHandler –
  • resultHandler –
/** * Like {@link io.vertx.reactivex.core.Vertx#executeBlocking} called with ordered = true. * @param blockingCodeHandler * @param resultHandler */
public <T> void executeBlocking(Handler<io.vertx.reactivex.core.Promise<T>> blockingCodeHandler, Handler<AsyncResult<T>> resultHandler) { delegate.executeBlocking(new Handler<io.vertx.core.Promise<T>>() { public void handle(io.vertx.core.Promise<T> event) { blockingCodeHandler.handle(io.vertx.reactivex.core.Promise.newInstance(event, io.vertx.lang.rx.TypeArg.unknown())); } }, resultHandler); }
Like executeBlocking called with ordered = true.
Params:
  • blockingCodeHandler –
Returns:
/** * Like {@link io.vertx.reactivex.core.Vertx#executeBlocking} called with ordered = true. * @param blockingCodeHandler * @return */
public <T> Maybe<T> rxExecuteBlocking(Handler<io.vertx.reactivex.core.Promise<T>> blockingCodeHandler) { return io.vertx.reactivex.impl.AsyncResultMaybe.toMaybe(handler -> { executeBlocking(blockingCodeHandler, handler); }); }
Like createSharedWorkerExecutor but with the VertxOptions poolSize.
Params:
  • name –
Returns:
/** * Like {@link io.vertx.reactivex.core.Vertx#createSharedWorkerExecutor} but with the {@link io.vertx.core.VertxOptions} <code>poolSize</code>. * @param name * @return */
public io.vertx.reactivex.core.WorkerExecutor createSharedWorkerExecutor(String name) { io.vertx.reactivex.core.WorkerExecutor ret = io.vertx.reactivex.core.WorkerExecutor.newInstance(delegate.createSharedWorkerExecutor(name)); return ret; }
Like createSharedWorkerExecutor but with the VertxOptions maxExecuteTime.
Params:
  • name –
  • poolSize –
Returns:
/** * Like {@link io.vertx.reactivex.core.Vertx#createSharedWorkerExecutor} but with the {@link io.vertx.core.VertxOptions} <code>maxExecuteTime</code>. * @param name * @param poolSize * @return */
public io.vertx.reactivex.core.WorkerExecutor createSharedWorkerExecutor(String name, int poolSize) { io.vertx.reactivex.core.WorkerExecutor ret = io.vertx.reactivex.core.WorkerExecutor.newInstance(delegate.createSharedWorkerExecutor(name, poolSize)); return ret; }
Like createSharedWorkerExecutor but with the .
Params:
  • name –
  • poolSize –
  • maxExecuteTime –
Returns:
/** * Like {@link io.vertx.reactivex.core.Vertx#createSharedWorkerExecutor} but with the . * @param name * @param poolSize * @param maxExecuteTime * @return */
public io.vertx.reactivex.core.WorkerExecutor createSharedWorkerExecutor(String name, int poolSize, long maxExecuteTime) { io.vertx.reactivex.core.WorkerExecutor ret = io.vertx.reactivex.core.WorkerExecutor.newInstance(delegate.createSharedWorkerExecutor(name, poolSize, maxExecuteTime)); return ret; }
Create a named worker executor, the executor should be closed when it's not needed anymore to release resources.

This method can be called mutiple times with the same name. Executors with the same name will share the same worker pool. The worker pool size , max execute time and unit of max execute time are set when the worker pool is created and won't change after.

The worker pool is released when all the WorkerExecutor sharing the same name are closed.

Params:
  • name – the name of the worker executor
  • poolSize – the size of the pool
  • maxExecuteTime – the value of max worker execute time
  • maxExecuteTimeUnit – the value of unit of max worker execute time
Returns:the named worker executor
/** * Create a named worker executor, the executor should be closed when it's not needed anymore to release * resources.<p/> * * This method can be called mutiple times with the same <code>name</code>. Executors with the same name will share * the same worker pool. The worker pool size , max execute time and unit of max execute time are set when the worker pool is created and * won't change after.<p> * * The worker pool is released when all the {@link io.vertx.reactivex.core.WorkerExecutor} sharing the same name are closed. * @param name the name of the worker executor * @param poolSize the size of the pool * @param maxExecuteTime the value of max worker execute time * @param maxExecuteTimeUnit the value of unit of max worker execute time * @return the named worker executor */
public io.vertx.reactivex.core.WorkerExecutor createSharedWorkerExecutor(String name, int poolSize, long maxExecuteTime, TimeUnit maxExecuteTimeUnit) { io.vertx.reactivex.core.WorkerExecutor ret = io.vertx.reactivex.core.WorkerExecutor.newInstance(delegate.createSharedWorkerExecutor(name, poolSize, maxExecuteTime, maxExecuteTimeUnit)); return ret; }
Returns:whether the native transport is used
/** * @return whether the native transport is used */
public boolean isNativeTransportEnabled() { if (cached_3 != null) { return cached_3; } boolean ret = delegate.isNativeTransportEnabled(); cached_3 = ret; return ret; }
Set a default exception handler for Context, set on at creation.
Params:
  • handler – the exception handler
Returns:a reference to this, so the API can be used fluently
/** * Set a default exception handler for {@link io.vertx.reactivex.core.Context}, set on at creation. * @param handler the exception handler * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.core.Vertx exceptionHandler(Handler<Throwable> handler) { delegate.exceptionHandler(handler); return this; }
Deploy a verticle instance that you have created yourself.

Vert.x will assign the verticle a context and start the verticle.

The actual deploy happens asynchronously and may not complete until after the call has returned.

Params:
  • verticle – the verticle instance to deploy.
/** * Deploy a verticle instance that you have created yourself. * <p> * Vert.x will assign the verticle a context and start the verticle. * <p> * The actual deploy happens asynchronously and may not complete until after the call has returned. * @param verticle the verticle instance to deploy. */
public void deployVerticle(Verticle verticle) { delegate.deployVerticle(verticle); }
Like deployVerticle but the completionHandler will be notified when the deployment is complete.

If the deployment is successful the result will contain a string representing the unique deployment ID of the deployment.

This deployment ID can subsequently be used to undeploy the verticle.

Params:
  • verticle – the verticle instance to deploy
  • completionHandler – a handler which will be notified when the deployment is complete
/** * Like {@link io.vertx.reactivex.core.Vertx#deployVerticle} but the completionHandler will be notified when the deployment is complete. * <p> * If the deployment is successful the result will contain a string representing the unique deployment ID of the * deployment. * <p> * This deployment ID can subsequently be used to undeploy the verticle. * @param verticle the verticle instance to deploy * @param completionHandler a handler which will be notified when the deployment is complete */
public void deployVerticle(Verticle verticle, Handler<AsyncResult<String>> completionHandler) { delegate.deployVerticle(verticle, completionHandler); }
Like deployVerticle but the completionHandler will be notified when the deployment is complete.

If the deployment is successful the result will contain a string representing the unique deployment ID of the deployment.

This deployment ID can subsequently be used to undeploy the verticle.

Params:
  • verticle – the verticle instance to deploy
Returns:
/** * Like {@link io.vertx.reactivex.core.Vertx#deployVerticle} but the completionHandler will be notified when the deployment is complete. * <p> * If the deployment is successful the result will contain a string representing the unique deployment ID of the * deployment. * <p> * This deployment ID can subsequently be used to undeploy the verticle. * @param verticle the verticle instance to deploy * @return */
public Single<String> rxDeployVerticle(Verticle verticle) { return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> { deployVerticle(verticle, handler); }); }
Like deployVerticle but DeploymentOptions are provided to configure the deployment.
Params:
  • verticle – the verticle instance to deploy
  • options – the deployment options.
/** * Like {@link io.vertx.reactivex.core.Vertx#deployVerticle} but {@link io.vertx.core.DeploymentOptions} are provided to configure the * deployment. * @param verticle the verticle instance to deploy * @param options the deployment options. */
public void deployVerticle(Verticle verticle, DeploymentOptions options) { delegate.deployVerticle(verticle, options); }
Like deployVerticle but Verticle instance is created by invoking the verticleSupplier.

The supplier will be invoked as many times as DeploymentOptions. It must not return the same instance twice.

Note that the supplier will be invoked on the caller thread.

Params:
  • verticleSupplier –
  • options –
/** * Like {@link io.vertx.reactivex.core.Vertx#deployVerticle} but {@link io.vertx.core.Verticle} instance is created by invoking the * <code>verticleSupplier</code>. * <p> * The supplier will be invoked as many times as {@link io.vertx.core.DeploymentOptions}. * It must not return the same instance twice. * <p> * Note that the supplier will be invoked on the caller thread. * @param verticleSupplier * @param options */
public void deployVerticle(Supplier<Verticle> verticleSupplier, DeploymentOptions options) { delegate.deployVerticle(verticleSupplier, options); }
Like deployVerticle but DeploymentOptions are provided to configure the deployment.
Params:
  • verticle – the verticle instance to deploy
  • options – the deployment options.
  • completionHandler – a handler which will be notified when the deployment is complete
/** * Like {@link io.vertx.reactivex.core.Vertx#deployVerticle} but {@link io.vertx.core.DeploymentOptions} are provided to configure the * deployment. * @param verticle the verticle instance to deploy * @param options the deployment options. * @param completionHandler a handler which will be notified when the deployment is complete */
public void deployVerticle(Verticle verticle, DeploymentOptions options, Handler<AsyncResult<String>> completionHandler) { delegate.deployVerticle(verticle, options, completionHandler); }
Like deployVerticle but DeploymentOptions are provided to configure the deployment.
Params:
  • verticle – the verticle instance to deploy
  • options – the deployment options.
Returns:
/** * Like {@link io.vertx.reactivex.core.Vertx#deployVerticle} but {@link io.vertx.core.DeploymentOptions} are provided to configure the * deployment. * @param verticle the verticle instance to deploy * @param options the deployment options. * @return */
public Single<String> rxDeployVerticle(Verticle verticle, DeploymentOptions options) { return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> { deployVerticle(verticle, options, handler); }); }
Like deployVerticle but Verticle instance is created by invoking the verticleSupplier.

The supplier will be invoked as many times as DeploymentOptions. It must not return the same instance twice.

Note that the supplier will be invoked on the caller thread.

Params:
  • verticleSupplier –
  • options –
  • completionHandler –
/** * Like {@link io.vertx.reactivex.core.Vertx#deployVerticle} but {@link io.vertx.core.Verticle} instance is created by * invoking the <code>verticleSupplier</code>. * <p> * The supplier will be invoked as many times as {@link io.vertx.core.DeploymentOptions}. * It must not return the same instance twice. * <p> * Note that the supplier will be invoked on the caller thread. * @param verticleSupplier * @param options * @param completionHandler */
public void deployVerticle(Supplier<Verticle> verticleSupplier, DeploymentOptions options, Handler<AsyncResult<String>> completionHandler) { delegate.deployVerticle(verticleSupplier, options, completionHandler); }
Like deployVerticle but Verticle instance is created by invoking the verticleSupplier.

The supplier will be invoked as many times as DeploymentOptions. It must not return the same instance twice.

Note that the supplier will be invoked on the caller thread.

Params:
  • verticleSupplier –
  • options –
Returns:
/** * Like {@link io.vertx.reactivex.core.Vertx#deployVerticle} but {@link io.vertx.core.Verticle} instance is created by * invoking the <code>verticleSupplier</code>. * <p> * The supplier will be invoked as many times as {@link io.vertx.core.DeploymentOptions}. * It must not return the same instance twice. * <p> * Note that the supplier will be invoked on the caller thread. * @param verticleSupplier * @param options * @return */
public Single<String> rxDeployVerticle(Supplier<Verticle> verticleSupplier, DeploymentOptions options) { return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> { deployVerticle(verticleSupplier, options, handler); }); }
Register a VerticleFactory that can be used for deploying Verticles based on an identifier.
Params:
  • factory – the factory to register
/** * Register a <code>VerticleFactory</code> that can be used for deploying Verticles based on an identifier. * @param factory the factory to register */
public void registerVerticleFactory(VerticleFactory factory) { delegate.registerVerticleFactory(factory); }
Unregister a VerticleFactory
Params:
  • factory – the factory to unregister
/** * Unregister a <code>VerticleFactory</code> * @param factory the factory to unregister */
public void unregisterVerticleFactory(VerticleFactory factory) { delegate.unregisterVerticleFactory(factory); }
Return the Set of currently registered verticle factories.
Returns:the set of verticle factories
/** * Return the Set of currently registered verticle factories. * @return the set of verticle factories */
public Set<VerticleFactory> verticleFactories() { Set<VerticleFactory> ret = delegate.verticleFactories(); return ret; }
Return the Netty EventLoopGroup used by Vert.x
Returns:the EventLoopGroup
/** * Return the Netty EventLoopGroup used by Vert.x * @return the EventLoopGroup */
public EventLoopGroup nettyEventLoopGroup() { EventLoopGroup ret = delegate.nettyEventLoopGroup(); return ret; } private io.vertx.reactivex.core.file.FileSystem cached_0; private io.vertx.reactivex.core.eventbus.EventBus cached_1; private io.vertx.reactivex.core.shareddata.SharedData cached_2; private java.lang.Boolean cached_3; public static Vertx newInstance(io.vertx.core.Vertx arg) { return arg != null ? new Vertx(arg) : null; } }