public class Vertx extends Object implements Measured
You use an instance of this class for functionality including:
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(io.vertx.core.VertxOptions)
.
Please see the user manual for more detailed usage information.
NOTE: This class has been automatically generated from theoriginal
non RX-ified interface using Vert.x codegen.Modifier and Type | Field and Description |
---|---|
static io.vertx.lang.rx.TypeArg<Vertx> |
__TYPE_ARG |
Constructor and Description |
---|
Vertx(Object delegate) |
Vertx(Vertx delegate) |
Modifier and Type | Method and Description |
---|---|
static VertxBuilder |
builder() |
boolean |
cancelTimer(long id)
Cancels the timer with the specified
id . |
Completable |
close()
Like
close() but the completionHandler will be called when the close is complete |
static Single<Vertx> |
clusteredVertx(VertxOptions options)
Creates a clustered instance using the specified options.
|
DatagramSocket |
createDatagramSocket()
Create a datagram socket using default options
|
DatagramSocket |
createDatagramSocket(DatagramSocketOptions options)
Create a datagram socket using the specified options
|
DnsClient |
createDnsClient()
Create a DNS client to connect to the DNS server configured by
VertxOptions |
DnsClient |
createDnsClient(DnsClientOptions options)
Create a DNS client to connect to a DNS server
|
DnsClient |
createDnsClient(int port,
String host)
Create a DNS client to connect to a DNS server at the specified host and port, with the default query timeout (5 seconds)
|
HttpClient |
createHttpClient()
Create a HTTP/HTTPS client using default options
|
HttpClient |
createHttpClient(HttpClientOptions clientOptions)
Create a HTTP/HTTPS client using the specified client options
|
HttpClient |
createHttpClient(HttpClientOptions clientOptions,
PoolOptions poolOptions)
Create a HTTP/HTTPS client using the specified client and pool options
|
HttpClient |
createHttpClient(PoolOptions poolOptions)
Create a HTTP/HTTPS client using the specified pool options
|
HttpServer |
createHttpServer()
Create an HTTP/HTTPS server using default options
|
HttpServer |
createHttpServer(HttpServerOptions options)
Create an HTTP/HTTPS server using the specified options
|
NetClient |
createNetClient()
Create a TCP/SSL client using default options
|
NetClient |
createNetClient(NetClientOptions options)
Create a TCP/SSL client using the specified options
|
NetServer |
createNetServer()
Create a TCP/SSL server using default options
|
NetServer |
createNetServer(NetServerOptions options)
Create a TCP/SSL server using the specified options
|
WorkerExecutor |
createSharedWorkerExecutor(String name)
|
WorkerExecutor |
createSharedWorkerExecutor(String name,
int poolSize)
|
WorkerExecutor |
createSharedWorkerExecutor(String name,
int poolSize,
long maxExecuteTime)
|
WorkerExecutor |
createSharedWorkerExecutor(String name,
int poolSize,
long maxExecuteTime,
TimeUnit maxExecuteTimeUnit)
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 . |
WebSocketClient |
createWebSocketClient()
Create a WebSocket client using default options
|
WebSocketClient |
createWebSocketClient(WebSocketClientOptions options)
Create a WebSocket client using the specified options
|
static Context |
currentContext()
Gets the current context
|
Set<String> |
deploymentIDs()
Return a Set of deployment IDs for the currently deployed deploymentIDs.
|
Single<String> |
deployVerticle(String name)
Like
deployVerticle(java.lang.String) but the completionHandler will be notified when the deployment is complete. |
Single<String> |
deployVerticle(String name,
DeploymentOptions options)
Like
deployVerticle(java.lang.String) but DeploymentOptions are provided to configure the
deployment. |
Single<String> |
deployVerticle(java.util.function.Supplier<Verticle> verticleSupplier,
DeploymentOptions options)
Like
deployVerticle(java.lang.String) but Verticle instance is created by
invoking the verticleSupplier . |
Single<String> |
deployVerticle(Verticle verticle)
Like
deployVerticle(java.lang.String) but the completionHandler will be notified when the deployment is complete. |
Single<String> |
deployVerticle(Verticle verticle,
DeploymentOptions options)
Like
deployVerticle(java.lang.String) but DeploymentOptions are provided to configure the
deployment. |
boolean |
equals(Object o) |
EventBus |
eventBus()
Get the event bus object.
|
Vertx |
exceptionHandler(Handler<Throwable> handler)
Set a default exception handler for
Context , set on Context.exceptionHandler(io.vertx.core.Handler<java.lang.Throwable>) at creation. |
<T> Maybe<T> |
executeBlocking(Callable<T> blockingCodeHandler)
Like
executeBlocking(io.vertx.core.Handler<io.vertx.rxjava3.core.Promise<T>>, boolean) but using a callback. |
<T> Maybe<T> |
executeBlocking(Callable<T> blockingCodeHandler,
boolean ordered)
Like
executeBlocking(io.vertx.core.Handler<io.vertx.rxjava3.core.Promise<T>>, boolean) but using a callback. |
<T> Maybe<T> |
executeBlocking(Handler<Promise<T>> blockingCodeHandler)
Deprecated.
|
<T> Maybe<T> |
executeBlocking(Handler<Promise<T>> blockingCodeHandler,
boolean ordered)
Deprecated.
|
FileSystem |
fileSystem()
Get the filesystem object.
|
Vertx |
getDelegate() |
Context |
getOrCreateContext()
Gets the current context, or creates one if there isn't one
|
int |
hashCode() |
HttpClientBuilder |
httpClientBuilder()
Provide a builder for , it can be used to configure advanced
HTTP client settings like a redirect handler or a connection handler.
|
boolean |
isClustered()
Is this Vert.x instance clustered?
|
boolean |
isMetricsEnabled()
Whether the metrics are enabled for this measured object
|
boolean |
isNativeTransportEnabled() |
EventLoopGroup |
nettyEventLoopGroup()
Deprecated.
|
static Vertx |
newInstance(Vertx arg) |
TimeoutStream |
periodicStream(long delay)
Deprecated.
|
TimeoutStream |
periodicStream(long initialDelay,
long delay)
Deprecated.
|
void |
registerVerticleFactory(VerticleFactory factory)
Register a
VerticleFactory that can be used for deploying Verticles based on an identifier. |
void |
runOnContext(Handler<Void> action)
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.
|
Completable |
rxClose()
Like
close() but the completionHandler will be called when the close is complete |
static Single<Vertx> |
rxClusteredVertx(VertxOptions options)
Creates a clustered instance using the specified options.
|
Single<String> |
rxDeployVerticle(String name)
Like
deployVerticle(java.lang.String) but the completionHandler will be notified when the deployment is complete. |
Single<String> |
rxDeployVerticle(String name,
DeploymentOptions options)
Like
deployVerticle(java.lang.String) but DeploymentOptions are provided to configure the
deployment. |
Single<String> |
rxDeployVerticle(java.util.function.Supplier<Verticle> verticleSupplier,
DeploymentOptions options)
Like
deployVerticle(java.lang.String) but Verticle instance is created by
invoking the verticleSupplier . |
Single<String> |
rxDeployVerticle(Verticle verticle)
Like
deployVerticle(java.lang.String) but the completionHandler will be notified when the deployment is complete. |
Single<String> |
rxDeployVerticle(Verticle verticle,
DeploymentOptions options)
Like
deployVerticle(java.lang.String) but DeploymentOptions are provided to configure the
deployment. |
<T> Maybe<T> |
rxExecuteBlocking(Callable<T> blockingCodeHandler)
Like
executeBlocking(io.vertx.core.Handler<io.vertx.rxjava3.core.Promise<T>>, boolean) but using a callback. |
<T> Maybe<T> |
rxExecuteBlocking(Callable<T> blockingCodeHandler,
boolean ordered)
Like
executeBlocking(io.vertx.core.Handler<io.vertx.rxjava3.core.Promise<T>>, boolean) but using a callback. |
<T> Maybe<T> |
rxExecuteBlocking(Handler<Promise<T>> blockingCodeHandler)
Deprecated.
|
<T> Maybe<T> |
rxExecuteBlocking(Handler<Promise<T>> blockingCodeHandler,
boolean ordered)
Deprecated.
|
Completable |
rxUndeploy(String deploymentID)
Like
#undeploy(String) but the completionHandler will be notified when the undeployment is complete. |
long |
setPeriodic(long delay,
Handler<Long> handler)
Set a periodic timer to fire every
delay milliseconds, at which point handler will be called with
the id of the timer. |
long |
setPeriodic(long initialDelay,
long delay,
Handler<Long> handler)
Set a periodic timer to fire every
delay milliseconds with initial delay, at which point handler will be called with
the id of the timer. |
long |
setTimer(long delay,
Handler<Long> handler)
Set a one-shot timer to fire after
delay milliseconds, at which point handler will be called with
the id of the timer. |
SharedData |
sharedData()
Get the shared data object.
|
Timer |
timer(long delay)
Like
timer(long) with a unit in millis. |
Timer |
timer(long delay,
TimeUnit unit)
Create a timer task configured with the specified
delay , when the timeout fires the timer future
is succeeded, when the timeout is cancelled the timer future is failed with a CancellationException
instance. |
TimeoutStream |
timerStream(long delay)
Deprecated.
|
String |
toString() |
Throwable |
unavailableNativeTransportCause() |
Completable |
undeploy(String deploymentID)
Like
#undeploy(String) but the completionHandler will be notified when the undeployment is complete. |
void |
unregisterVerticleFactory(VerticleFactory factory)
Unregister a
VerticleFactory |
Set<VerticleFactory> |
verticleFactories()
Return the Set of currently registered verticle factories.
|
static Vertx |
vertx()
Creates a non clustered instance using default options.
|
static Vertx |
vertx(VertxOptions options)
Creates a non clustered instance using the specified options
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
newInstance
public static final io.vertx.lang.rx.TypeArg<Vertx> __TYPE_ARG
public Vertx getDelegate()
getDelegate
in interface Measured
public boolean isMetricsEnabled()
isMetricsEnabled
in interface Measured
true
if metrics are enabledpublic static VertxBuilder builder()
public static Vertx vertx()
public static Vertx vertx(VertxOptions options)
options
- the options to usepublic static Single<Vertx> clusteredVertx(VertxOptions options)
The instance is created asynchronously and the resultHandler is called with the result when it is ready.
options
- the options to usepublic static Single<Vertx> rxClusteredVertx(VertxOptions options)
The instance is created asynchronously and the resultHandler is called with the result when it is ready.
options
- the options to usepublic static Context currentContext()
null
if there is no current contextpublic Context getOrCreateContext()
public NetServer createNetServer(NetServerOptions options)
options
- the options to usepublic NetServer createNetServer()
public NetClient createNetClient(NetClientOptions options)
options
- the options to usepublic NetClient createNetClient()
public HttpServer createHttpServer(HttpServerOptions options)
options
- the options to usepublic HttpServer createHttpServer()
public WebSocketClient createWebSocketClient()
public WebSocketClient createWebSocketClient(WebSocketClientOptions options)
options
- the options to usepublic HttpClientBuilder httpClientBuilder()
Example usage: HttpClient client = vertx.httpClientBuilder().with(options).withConnectHandler(conn -> ...).build()
public HttpClient createHttpClient(HttpClientOptions clientOptions, PoolOptions poolOptions)
clientOptions
- the client options to usepoolOptions
- the pool options to usepublic HttpClient createHttpClient(HttpClientOptions clientOptions)
clientOptions
- the options to usepublic HttpClient createHttpClient(PoolOptions poolOptions)
poolOptions
- the pool options to usepublic HttpClient createHttpClient()
public DatagramSocket createDatagramSocket(DatagramSocketOptions options)
options
- the options to usepublic DatagramSocket createDatagramSocket()
public FileSystem fileSystem()
public EventBus eventBus()
public DnsClient createDnsClient(int port, String host)
port
- the porthost
- the hostpublic DnsClient createDnsClient()
VertxOptions
DNS client takes the first configured resolver address provided by }
public DnsClient createDnsClient(DnsClientOptions options)
options
- the client optionspublic SharedData sharedData()
public Timer timer(long delay)
timer(long)
with a unit in millis.delay
- public Timer timer(long delay, TimeUnit unit)
delay
, when the timeout fires the timer future
is succeeded, when the timeout is cancelled the timer future is failed with a CancellationException
instance.delay
- the delayunit
- the delay unitpublic long setTimer(long delay, Handler<Long> handler)
delay
milliseconds, at which point handler
will be called with
the id of the timer.delay
- the delay in milliseconds, after which the timer will firehandler
- the handler that will be called with the timer ID when the timer fires@Deprecated public TimeoutStream timerStream(long delay)
delay
milliseconds after
the has been called.delay
- the delay in milliseconds, after which the timer will firepublic long setPeriodic(long delay, Handler<Long> handler)
delay
milliseconds, at which point handler
will be called with
the id of the timer.delay
- the delay in milliseconds, after which the timer will firehandler
- the handler that will be called with the timer ID when the timer firespublic long setPeriodic(long initialDelay, long delay, Handler<Long> handler)
delay
milliseconds with initial delay, at which point handler
will be called with
the id of the timer.initialDelay
- the initial delay in millisecondsdelay
- the delay in milliseconds, after which the timer will firehandler
- the handler that will be called with the timer ID when the timer fires@Deprecated public TimeoutStream periodicStream(long delay)
delay
milliseconds after
the has been called.delay
- the delay in milliseconds, after which the timer will fire@Deprecated public TimeoutStream periodicStream(long initialDelay, long delay)
delay
milliseconds after
the has been called.initialDelay
- the initial delay in millisecondsdelay
- the delay in milliseconds, after which the timer will firepublic boolean cancelTimer(long id)
id
.id
- The id of the timer to cancelpublic void runOnContext(Handler<Void> action)
action
- - a handler representing the action to executepublic Completable close()
close()
but the completionHandler will be called when the close is completepublic Completable rxClose()
close()
but the completionHandler will be called when the close is completepublic Single<String> deployVerticle(String name)
deployVerticle(java.lang.String)
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.
name
- The identifierpublic Single<String> rxDeployVerticle(String name)
deployVerticle(java.lang.String)
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.
name
- The identifierpublic Single<String> deployVerticle(String name, DeploymentOptions options)
deployVerticle(java.lang.String)
but DeploymentOptions
are provided to configure the
deployment.name
- the nameoptions
- the deployment options.public Single<String> rxDeployVerticle(String name, DeploymentOptions options)
deployVerticle(java.lang.String)
but DeploymentOptions
are provided to configure the
deployment.name
- the nameoptions
- the deployment options.public Completable undeploy(String deploymentID)
#undeploy(String)
but the completionHandler will be notified when the undeployment is complete.deploymentID
- the deployment IDpublic Completable rxUndeploy(String deploymentID)
#undeploy(String)
but the completionHandler will be notified when the undeployment is complete.deploymentID
- the deployment IDpublic Set<String> deploymentIDs()
public boolean isClustered()
@Deprecated public <T> Maybe<T> executeBlocking(Handler<Promise<T>> blockingCodeHandler, boolean ordered)
Executes the blocking code in the handler blockingCodeHandler
using a thread from the worker pool.
The returned future will be completed with the result on the original context (i.e. on the original event loop of the caller) or failed when the handler throws an exception.
A Future
instance is passed into blockingCodeHandler
. When the blocking code successfully completes,
the handler should call the Promise.complete(T)
or Promise.complete(T)
method, or the Promise.fail(java.lang.Throwable)
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 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(io.vertx.core.Handler<java.lang.Void>)
blockingCodeHandler
- handler representing the blocking code to runordered
- 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@Deprecated public <T> Maybe<T> rxExecuteBlocking(Handler<Promise<T>> blockingCodeHandler, boolean ordered)
Executes the blocking code in the handler blockingCodeHandler
using a thread from the worker pool.
The returned future will be completed with the result on the original context (i.e. on the original event loop of the caller) or failed when the handler throws an exception.
A Future
instance is passed into blockingCodeHandler
. When the blocking code successfully completes,
the handler should call the Promise.complete(T)
or Promise.complete(T)
method, or the Promise.fail(java.lang.Throwable)
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 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(io.vertx.core.Handler<java.lang.Void>)
blockingCodeHandler
- handler representing the blocking code to runordered
- 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@Deprecated public <T> Maybe<T> executeBlocking(Handler<Promise<T>> blockingCodeHandler)
executeBlocking(io.vertx.core.Handler<io.vertx.rxjava3.core.Promise<T>>, boolean)
called with ordered = true.blockingCodeHandler
- @Deprecated public <T> Maybe<T> rxExecuteBlocking(Handler<Promise<T>> blockingCodeHandler)
executeBlocking(io.vertx.core.Handler<io.vertx.rxjava3.core.Promise<T>>, boolean)
called with ordered = true.blockingCodeHandler
- public WorkerExecutor createSharedWorkerExecutor(String name)
name
- public WorkerExecutor createSharedWorkerExecutor(String name, int poolSize)
name
- poolSize
- public WorkerExecutor createSharedWorkerExecutor(String name, int poolSize, long maxExecuteTime)
name
- poolSize
- maxExecuteTime
- public WorkerExecutor createSharedWorkerExecutor(String name, int poolSize, long maxExecuteTime, TimeUnit maxExecuteTimeUnit)
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.
name
- the name of the worker executorpoolSize
- the size of the poolmaxExecuteTime
- the value of max worker execute timemaxExecuteTimeUnit
- the value of unit of max worker execute timepublic boolean isNativeTransportEnabled()
public Throwable unavailableNativeTransportCause()
isNativeTransportEnabled()
returns false
.public Vertx exceptionHandler(Handler<Throwable> handler)
Context
, set on Context.exceptionHandler(io.vertx.core.Handler<java.lang.Throwable>)
at creation.handler
- the exception handlerpublic Single<String> deployVerticle(Verticle verticle)
deployVerticle(java.lang.String)
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.
verticle
- the verticle instance to deploypublic Single<String> rxDeployVerticle(Verticle verticle)
deployVerticle(java.lang.String)
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.
verticle
- the verticle instance to deploypublic Single<String> deployVerticle(Verticle verticle, DeploymentOptions options)
deployVerticle(java.lang.String)
but DeploymentOptions
are provided to configure the
deployment.verticle
- the verticle instance to deployoptions
- the deployment options.public Single<String> rxDeployVerticle(Verticle verticle, DeploymentOptions options)
deployVerticle(java.lang.String)
but DeploymentOptions
are provided to configure the
deployment.verticle
- the verticle instance to deployoptions
- the deployment options.public Single<String> deployVerticle(java.util.function.Supplier<Verticle> verticleSupplier, DeploymentOptions options)
deployVerticle(java.lang.String)
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.
verticleSupplier
- options
- public Single<String> rxDeployVerticle(java.util.function.Supplier<Verticle> verticleSupplier, DeploymentOptions options)
deployVerticle(java.lang.String)
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.
verticleSupplier
- options
- public void registerVerticleFactory(VerticleFactory factory)
VerticleFactory
that can be used for deploying Verticles based on an identifier.factory
- the factory to registerpublic void unregisterVerticleFactory(VerticleFactory factory)
VerticleFactory
factory
- the factory to unregisterpublic Set<VerticleFactory> verticleFactories()
public <T> Maybe<T> executeBlocking(Callable<T> blockingCodeHandler)
executeBlocking(io.vertx.core.Handler<io.vertx.rxjava3.core.Promise<T>>, boolean)
but using a callback.blockingCodeHandler
- public <T> Maybe<T> rxExecuteBlocking(Callable<T> blockingCodeHandler)
executeBlocking(io.vertx.core.Handler<io.vertx.rxjava3.core.Promise<T>>, boolean)
but using a callback.blockingCodeHandler
- public <T> Maybe<T> executeBlocking(Callable<T> blockingCodeHandler, boolean ordered)
executeBlocking(io.vertx.core.Handler<io.vertx.rxjava3.core.Promise<T>>, boolean)
but using a callback.blockingCodeHandler
- ordered
- public <T> Maybe<T> rxExecuteBlocking(Callable<T> blockingCodeHandler, boolean ordered)
executeBlocking(io.vertx.core.Handler<io.vertx.rxjava3.core.Promise<T>>, boolean)
but using a callback.blockingCodeHandler
- ordered
- @Deprecated public EventLoopGroup nettyEventLoopGroup()
Copyright © 2024 Eclipse. All rights reserved.