Top Description Methods
io.vertx.core

public Interface Vertx

extends Measured
Known Direct Subinterfaces
io.vertx.core.impl.VertxInternal
Annotations
@VertxGen
Imports
io.netty.channel.EventLoopGroup, io.vertx.codegen.annotations.*, io.vertx.core.datagram.DatagramSocket, .DatagramSocketOptions, io.vertx.core.dns.DnsClient, .DnsClientOptions, io.vertx.core.eventbus.EventBus, io.vertx.core.file.FileSystem, io.vertx.core.http.*, io.vertx.core.impl.ContextInternal, .VertxImpl, io.vertx.core.metrics.Measured, .MetricsOptions, io.vertx.core.net.NetClient, .NetClientOptions, .NetServer, .NetServerOptions, io.vertx.core.shareddata.SharedData, io.vertx.core.spi.VerticleFactory, .VertxMetricsFactory, .VertxTracerFactory, io.vertx.core.spi.cluster.ClusterManager, io.vertx.core.streams.ReadStream, io.vertx.core.tracing.TracingOptions, java.util.Objects, .Set, java.util.concurrent.Callable, .TimeUnit, java.util.function.Supplier

The entry point into the Vert.x Core API.

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(io.vertx.core.VertxOptions) and clusteredVertx(io.vertx.core.VertxOptions, Handler).

Please see the user manual for more detailed usage information.

Authors
Tim Fox, Julien Viet

Method Summary

Modifier and TypeMethod and Description
public static VertxBuilder
public boolean

Returns:

true if the timer was successfully cancelled, or false if the timer does not exist.
cancelTimer
(long
The id of the timer to cancel
id
)

Cancels the timer with the specified id.

public Future<Void>

Returns:

a future completed with the result
close
()

Stop the Vertx instance and release any resources held by it.

public void
close(Handler<AsyncResult<Void>>
The handler will be notified when the close is complete.
completionHandler
)

Like close but the completionHandler will be called when the close is complete

public static void
clusteredVertx(VertxOptions
the options to use
options
,
Handler<AsyncResult<Vertx>>
the result handler that will receive the result
resultHandler
)

Creates a clustered instance using the specified options.

public static Future<Vertx>
clusteredVertx(VertxOptions options)

Same as clusteredVertx(VertxOptions, Handler) but with an handler called when the operation completes

public DatagramSocket

Returns:

the socket
createDatagramSocket
(DatagramSocketOptions
the options to use
options
)

Create a datagram socket using the specified options

public default DatagramSocket

Returns:

the socket
createDatagramSocket
()

Create a datagram socket using default options

public DnsClient

Returns:

the DNS client
createDnsClient
(int
the port
port
,
String
the host
host
)

Create a DNS client to connect to a DNS server at the specified host and port, with the default query timeout (5 seconds)

public DnsClient

Returns:

the DNS client
createDnsClient
()

Create a DNS client to connect to the DNS server configured by VertxOptions#getAddressResolverOptions()

DNS client takes the first configured resolver address provided by DnsResolverProvider#nameServerAddresses()}

public DnsClient

Returns:

the DNS client
createDnsClient
(DnsClientOptions
the client options
options
)

Create a DNS client to connect to a DNS server

public default HttpClient

Returns:

the client
createHttpClient
(HttpClientOptions
the client options to use
clientOptions
,
PoolOptions
the pool options to use
poolOptions
)

Create a HTTP/HTTPS client using the specified client and pool options

public default HttpClient

Returns:

the client
createHttpClient
(HttpClientOptions
the options to use
clientOptions
)

Create a HTTP/HTTPS client using the specified client options

public default HttpClient

Returns:

the client
createHttpClient
(PoolOptions
the pool options to use
poolOptions
)

Create a HTTP/HTTPS client using the specified pool options

public default HttpClient

Returns:

the client
createHttpClient
()

Create a HTTP/HTTPS client using default options

public HttpServer

Returns:

the server
createHttpServer
(HttpServerOptions
the options to use
options
)

Create an HTTP/HTTPS server using the specified options

public default HttpServer

Returns:

the server
createHttpServer
()

Create an HTTP/HTTPS server using default options

public NetClient

Returns:

the client
createNetClient
(NetClientOptions
the options to use
options
)

Create a TCP/SSL client using the specified options

public default NetClient

Returns:

the client
createNetClient
()

Create a TCP/SSL client using default options

public NetServer

Returns:

the server
createNetServer
(NetServerOptions
the options to use
options
)

Create a TCP/SSL server using the specified options

public default NetServer

Returns:

the server
createNetServer
()

Create a TCP/SSL server using default options

public WorkerExecutor
public WorkerExecutor
public WorkerExecutor
public WorkerExecutor

Returns:

the named worker executor
createSharedWorkerExecutor
(String
the name of the worker executor
name
,
int
the size of the pool
poolSize
,
long
the value of max worker execute time
maxExecuteTime
,
TimeUnit
the value of unit of max worker execute time
maxExecuteTimeUnit
)

Create a named worker executor, the executor should be closed when it's not needed anymore to release resources.

public default WebSocketClient

Returns:

the client
createWebSocketClient
()

Create a WebSocket client using default options

public WebSocketClient

Returns:

the client
createWebSocketClient
(WebSocketClientOptions
the options to use
options
)

Create a WebSocket client using the specified options

public static @Nullable Context

Returns:

The current context or null if there is no current context
currentContext
()

Gets the current context

public Set<String>

Returns:

Set of deployment IDs
deploymentIDs
()

Return a Set of deployment IDs for the currently deployed deploymentIDs.

public default Future<String>

Returns:

a future completed with the result
deployVerticle
(Verticle
the verticle instance to deploy.
verticle
)

Deploy a verticle instance that you have created yourself.

public void
deployVerticle(Verticle
the verticle instance to deploy
verticle
,
Handler<AsyncResult<String>>
a handler which will be notified when the deployment is complete
completionHandler
)

Like deployVerticle(Verticle) but the completionHandler will be notified when the deployment is complete.

public Future<String>

Returns:

a future completed with the result
deployVerticle
(Verticle
the verticle instance to deploy
verticle
,
DeploymentOptions
the deployment options.
options
)

Like deployVerticle(Verticle) but io.vertx.core.DeploymentOptions are provided to configure the deployment.

public Future<String>

Returns:

a future completed with the result
deployVerticle
(Class<? extends Verticle> verticleClass, DeploymentOptions options)

Like deployVerticle(Verticle, DeploymentOptions) but Verticle instance is created by invoking the default constructor of verticleClass.

public Future<String>

Returns:

a future completed with the result
deployVerticle
(Supplier<Verticle> verticleSupplier, DeploymentOptions options)

Like deployVerticle(Verticle, DeploymentOptions) but Verticle instance is created by invoking the verticleSupplier.

public void
deployVerticle(Verticle
the verticle instance to deploy
verticle
,
DeploymentOptions
the deployment options.
options
,
Handler<AsyncResult<String>>
a handler which will be notified when the deployment is complete
completionHandler
)

Like deployVerticle(Verticle, Handler) but io.vertx.core.DeploymentOptions are provided to configure the deployment.

public void
deployVerticle(Class<? extends Verticle> verticleClass, DeploymentOptions options, Handler<AsyncResult<String>> completionHandler)

Like deployVerticle(Verticle, DeploymentOptions, Handler) but Verticle instance is created by invoking the default constructor of verticleClass.

public void
deployVerticle(Supplier<Verticle> verticleSupplier, DeploymentOptions options, Handler<AsyncResult<String>> completionHandler)

Like deployVerticle(Verticle, DeploymentOptions, Handler) but Verticle instance is created by invoking the verticleSupplier.

public default Future<String>

Returns:

a future completed with the result
deployVerticle
(String
the name.
name
)

Deploy a verticle instance given a name.

public default void
deployVerticle(String
The identifier
name
,
Handler<AsyncResult<String>>
a handler which will be notified when the deployment is complete
completionHandler
)

Like deployVerticle(String) but the completionHandler will be notified when the deployment is complete.

public Future<String>

Returns:

a future completed with the result
deployVerticle
(String
the name
name
,
DeploymentOptions
the deployment options.
options
)

Like deployVerticle(Verticle) but io.vertx.core.DeploymentOptions are provided to configure the deployment.

public void
deployVerticle(String
the name
name
,
DeploymentOptions
the deployment options.
options
,
Handler<AsyncResult<String>>
a handler which will be notified when the deployment is complete
completionHandler
)

Like deployVerticle(String, Handler) but io.vertx.core.DeploymentOptions are provided to configure the deployment.

public EventBus

Returns:

the event bus object
eventBus
()

Get the event bus object.

public Vertx

Returns:

a reference to this, so the API can be used fluently
exceptionHandler
(@Nullable Handler<Throwable>
the exception handler
handler
)

Set a default exception handler for Context, set on Context#exceptionHandler(Handler) at creation.

public @Nullable Handler<Throwable>

Returns:

the current default exception handler
exceptionHandler
()

public default <
the type of the result
T
>
void
executeBlocking(Handler<Promise<T>>
handler representing the blocking code to run
blockingCodeHandler
,
boolean
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
ordered
,
Handler<AsyncResult<@Nullable T>>
handler that will be called when the blocking code is complete
resultHandler
)
Deprecated use instead executeBlocking(Callable, boolean)

Safely execute some blocking code.

public default <T> void
executeBlocking(Handler<Promise<T>> blockingCodeHandler, Handler<AsyncResult<@Nullable T>> resultHandler)
Deprecated instead use executeBlocking(Callable)

Like executeBlocking(Handler, boolean, Handler) called with ordered = true.

public default <T> Future<@Nullable T>
executeBlocking(Handler<Promise<T>> blockingCodeHandler, boolean ordered)
Deprecated instead use executeBlocking(Callable, boolean)

Same as executeBlocking(Handler, boolean, Handler) but with an handler called when the operation completes

public default <
the type of the result
T
>
Future<@Nullable T>

Returns:

a future completed when the blocking code is complete
executeBlocking
(Callable<T>
handler representing the blocking code to run
blockingCodeHandler
,
boolean
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
ordered
)

Safely execute some blocking code.

public default <T> void
executeBlocking(Callable<T> blockingCodeHandler, Handler<AsyncResult<@Nullable T>> resultHandler)

Like executeBlocking(Callable) but using a callback.

public default <T> void
executeBlocking(Callable<T> blockingCodeHandler, boolean ordered, Handler<AsyncResult<@Nullable T>> resultHandler)

Like executeBlocking(Callable, boolean) but using a callback.

public default <T> Future<@Nullable T>
executeBlocking(Handler<Promise<T>> blockingCodeHandler)
Deprecated instead use executeBlocking(Callable)

Same as executeBlocking(Handler, Handler) but with an handler called when the operation completes

public default <T> Future<@Nullable T>
executeBlocking(Callable<T> blockingCodeHandler)

Like executeBlocking(Callable, boolean) called with ordered = true.

public FileSystem

Returns:

the filesystem object
fileSystem
()

Get the filesystem object.

public Context

Returns:

The current context (created if didn't exist)
getOrCreateContext
()

Gets the current context, or creates one if there isn't one

public HttpClientBuilder
httpClientBuilder()

Provide a builder for HttpClient, it can be used to configure advanced HTTP client settings like a redirect handler or a connection handler.

public boolean

Returns:

true if clustered
isClustered
()

Is this Vert.x instance clustered?

public boolean

Returns:

whether the native transport is used
isNativeTransportEnabled
()

public EventLoopGroup

Returns:

the EventLoopGroup
nettyEventLoopGroup
()
Deprecated removed from public API in Vert.x 5

Return the Netty EventLoopGroup used by Vert.x

public default TimeoutStream

Returns:

the periodic stream
periodicStream
(long
the delay in milliseconds, after which the timer will fire
delay
)
Deprecated use Vertx#setPeriodic instead. RxJava like integrations should use the Vert.x scheduler integration.

Returns a periodic timer as a read stream.

public TimeoutStream

Returns:

the periodic stream
periodicStream
(long
the initial delay in milliseconds
initialDelay
,
long
the delay in milliseconds, after which the timer will fire
delay
)
Deprecated use Vertx#setPeriodic instead. RxJava like integrations should use the Vert.x scheduler integration.

Returns a periodic timer as a read stream.

public void
registerVerticleFactory(VerticleFactory
the factory to register
factory
)

Register a VerticleFactory that can be used for deploying Verticles based on an identifier.

public void
runOnContext(Handler<Void>
- a handler representing the action to execute
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.

public default long

Returns:

the unique ID of the timer
setPeriodic
(long
the delay in milliseconds, after which the timer will fire
delay
,
Handler<Long>
the handler that will be called with the timer ID when the timer fires
handler
)

Set a periodic timer to fire every delay milliseconds, at which point handler will be called with the id of the timer.

public long

Returns:

the unique ID of the timer
setPeriodic
(long
the initial delay in milliseconds
initialDelay
,
long
the delay in milliseconds, after which the timer will fire
delay
,
Handler<Long>
the handler that will be called with the timer ID when the timer fires
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.

public long

Returns:

the unique ID of the timer
setTimer
(long
the delay in milliseconds, after which the timer will fire
delay
,
Handler<Long>
the handler that will be called with the timer ID when the timer fires
handler
)

Set a one-shot timer to fire after delay milliseconds, at which point handler will be called with the id of the timer.

public SharedData

Returns:

the shared data object
sharedData
()

Get the shared data object.

public default Timer
timer(long delay)

Like timer(long, TimeUnit) with a unit in millis.

public Timer

Returns:

the timer object
timer
(long
the delay
delay
,
TimeUnit
the delay unit
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 java.util.concurrent.CancellationException instance.

public TimeoutStream

Returns:

the timer stream
timerStream
(long
the delay in milliseconds, after which the timer will fire
delay
)
Deprecated use Vertx#setTimer instead. RxJava like integrations should use the Vert.x scheduler integration.

Returns a one-shot timer as a read stream.

public Throwable

Returns:

the error (if any) that cause the unavailability of native transport when isNativeTransportEnabled() returns false.
unavailableNativeTransportCause
()

public Future<Void>

Returns:

a future completed with the result
undeploy
(String
the deployment ID
deploymentID
)

Undeploy a verticle deployment.

public void
undeploy(String
the deployment ID
deploymentID
,
Handler<AsyncResult<Void>>
a handler which will be notified when the undeployment is complete
completionHandler
)

Like undeploy(String) but the completionHandler will be notified when the undeployment is complete.

public void
unregisterVerticleFactory(VerticleFactory
the factory to unregister
factory
)

Unregister a VerticleFactory

public Set<VerticleFactory>

Returns:

the set of verticle factories
verticleFactories
()

Return the Set of currently registered verticle factories.

public static Vertx

Returns:

the instance
vertx
()

Creates a non clustered instance using default options.

public static Vertx

Returns:

the instance
vertx
(VertxOptions
the options to use
options
)

Creates a non clustered instance using the specified options

Inherited from io.vertx.core.metrics.Measured:
isMetricsEnabled