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.

no subtypes hierarchy

Initializer
Vertx(Vertx unknown)
Inherited Attributes
Attributes inherited from: Object
hash, string
Methods
cancelTimershared default Boolean cancelTimer(Integer id)

Cancels the timer with the specified id.

Parameters:
  • id

    The id of the timer to cancel

closeshared default void close()

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.

closeshared default void close(Anything(Throwable?) completionHandler)

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

Parameters:
  • completionHandler

    The handler will be notified when the close is complete.

createDatagramSocketshared default DatagramSocket createDatagramSocket()

Create a datagram socket using default options

createDatagramSocketshared default DatagramSocket createDatagramSocket(DatagramSocketOptions options)

Create a datagram socket using the specified options

Parameters:
  • options

    the options to use

createDnsClientshared default DnsClient createDnsClient()

Create a DNS client to connect to the DNS server configured by getAddressResolverOptions

DNS client takes the first configured resolver address provided by }

createDnsClientshared default DnsClient createDnsClient(DnsClientOptions options)

Create a DNS client to connect to a DNS server

Parameters:
  • options

    the client options

createDnsClientshared default DnsClient createDnsClient(Integer 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)

Parameters:
  • port

    the port

  • host

    the host

createHttpClientshared default HttpClient createHttpClient()

Create a HTTP/HTTPS client using default options

createHttpClientshared default HttpClient createHttpClient(HttpClientOptions options)

Create a HTTP/HTTPS client using the specified options

Parameters:
  • options

    the options to use

createHttpServershared default HttpServer createHttpServer()

Create an HTTP/HTTPS server using default options

createHttpServershared default HttpServer createHttpServer(HttpServerOptions options)

Create an HTTP/HTTPS server using the specified options

Parameters:
  • options

    the options to use

createNetClientshared default NetClient createNetClient()

Create a TCP/SSL client using default options

createNetClientshared default NetClient createNetClient(NetClientOptions options)

Create a TCP/SSL client using the specified options

Parameters:
  • options

    the options to use

createNetServershared default NetServer createNetServer()

Create a TCP/SSL server using default options

createNetServershared default NetServer createNetServer(NetServerOptions options)

Create a TCP/SSL server using the specified options

Parameters:
  • options

    the options to use

createSharedWorkerExecutorshared default WorkerExecutor createSharedWorkerExecutor(String name)

Like createSharedWorkerExecutor but with the setWorkerPoolSize poolSize.

createSharedWorkerExecutorshared default WorkerExecutor createSharedWorkerExecutor(String name, Integer poolSize)

Like createSharedWorkerExecutor but with the setMaxWorkerExecuteTime maxExecuteTime.

createSharedWorkerExecutorshared default WorkerExecutor createSharedWorkerExecutor(String name, Integer poolSize, Integer maxExecuteTime)

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 and 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.

Parameters:
  • name

    the name of the worker executor

  • poolSize

    the size of the pool

  • maxExecuteTime

    the value of max worker execute time, in ns

deployVerticleshared default void deployVerticle(String name)

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.

Parameters:
  • name

    the name.

deployVerticleshared default void deployVerticle(String name, Anything(Throwable|String) 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.

Parameters:
  • name

    The identifier

  • completionHandler

    a handler which will be notified when the deployment is complete

deployVerticleshared default void deployVerticle(String name, DeploymentOptions options)

Like deployVerticle but DeploymentOptions are provided to configure the deployment.

Parameters:
  • name

    the name

  • options

    the deployment options.

deployVerticleshared default void deployVerticle(String name, DeploymentOptions options, Anything(Throwable|String) completionHandler)

Like deployVerticle but DeploymentOptions are provided to configure the deployment.

Parameters:
  • name

    the name

  • options

    the deployment options.

  • completionHandler

    a handler which will be notified when the deployment is complete

deploymentIDsshared default Set<String> deploymentIDs()

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

eventBusshared default EventBus eventBus()

Get the event bus object. There is a single instance of EventBus per Vertx instance.

exceptionHandlershared default Vertx exceptionHandler(Anything(Throwable)? handler)

Set a default exception handler for Context, set on at creation.

Parameters:
  • handler

    the exception handler

executeBlockingshared default void executeBlocking<T>(Anything(Future<T?>) blockingCodeHandler, Anything(Throwable|T?) resultHandler)

Like executeBlocking called with ordered = true.

executeBlockingshared default void executeBlocking<T>(Anything(Future<T?>) blockingCodeHandler, Boolean ordered, Anything(Throwable|T?) 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 complete or complete method, or the 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.

Parameters:
  • 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

fileSystemshared default FileSystem fileSystem()

Get the filesystem object. There is a single instance of FileSystem per Vertx instance.

getOrCreateContextshared default Context getOrCreateContext()

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

isClusteredshared default Boolean isClustered()

Is this Vert.x instance clustered?

isMetricsEnabledshared actual default Boolean isMetricsEnabled()

Whether the metrics are enabled for this measured object

isNativeTransportEnabledshared default Boolean isNativeTransportEnabled()
periodicStreamshared default TimeoutStream periodicStream(Integer delay)

Returns a periodic timer as a read stream. The timer will be fired every delay milliseconds after the has been called.

Parameters:
  • delay

    the delay in milliseconds, after which the timer will fire

runOnContextshared default void runOnContext(Anything() 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.

Parameters:
  • action
    • a handler representing the action to execute
setPeriodicshared default Integer setPeriodic(Integer delay, Anything(Integer) handler)

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

Parameters:
  • 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

setTimershared default Integer setTimer(Integer delay, Anything(Integer) handler)

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

Parameters:
  • 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

sharedDatashared default SharedData sharedData()

Get the shared data object. There is a single instance of SharedData per Vertx instance.

timerStreamshared default TimeoutStream timerStream(Integer delay)

Returns a one-shot timer as a read stream. The timer will be fired after delay milliseconds after the has been called.

Parameters:
  • delay

    the delay in milliseconds, after which the timer will fire

undeployshared default void undeploy(String deploymentID)

Undeploy a verticle deployment.

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

Parameters:
  • deploymentID

    the deployment ID

undeployshared default void undeploy(String deploymentID, Anything(Throwable?) completionHandler)

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

Parameters:
  • deploymentID

    the deployment ID

  • completionHandler

    a handler which will be notified when the undeployment is complete

Inherited Methods
Methods inherited from: Object
equals
Methods inherited from: Measured