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, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.core.Vertx>>)
.
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 |
---|---|
boolean |
cancelTimer(long id)
Cancels the timer with the specified
id . |
void |
close()
Like
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but the completionHandler will be called when the close is complete |
void |
close(Handler<AsyncResult<Void>> completionHandler)
Like
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but the completionHandler will be called when the close is complete |
static void |
clusteredVertx(VertxOptions options)
Creates a clustered instance using the specified options.
|
static void |
clusteredVertx(VertxOptions options,
Handler<AsyncResult<Vertx>> resultHandler)
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 options)
Create a HTTP/HTTPS client using the specified 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 . |
static Context |
currentContext()
Gets the current context
|
Set<String> |
deploymentIDs()
Return a Set of deployment IDs for the currently deployed deploymentIDs.
|
void |
deployVerticle(String name)
Like
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>) but the completionHandler will be notified when the deployment is complete. |
void |
deployVerticle(String name,
DeploymentOptions options)
Like
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>) but DeploymentOptions are provided to configure the
deployment. |
void |
deployVerticle(String name,
DeploymentOptions options,
Handler<AsyncResult<String>> completionHandler)
Like
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>) but DeploymentOptions are provided to configure the
deployment. |
void |
deployVerticle(String name,
Handler<AsyncResult<String>> completionHandler)
Like
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>) but the completionHandler will be notified when the deployment is complete. |
void |
deployVerticle(java.util.function.Supplier<Verticle> verticleSupplier,
DeploymentOptions options)
Like
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>) but Verticle instance is created by
invoking the verticleSupplier . |
void |
deployVerticle(java.util.function.Supplier<Verticle> verticleSupplier,
DeploymentOptions options,
Handler<AsyncResult<String>> completionHandler)
Like
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>) but Verticle instance is created by
invoking the verticleSupplier . |
void |
deployVerticle(Verticle verticle)
Like
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>) but the completionHandler will be notified when the deployment is complete. |
void |
deployVerticle(Verticle verticle,
DeploymentOptions options)
Like
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>) but DeploymentOptions are provided to configure the
deployment. |
void |
deployVerticle(Verticle verticle,
DeploymentOptions options,
Handler<AsyncResult<String>> completionHandler)
Like
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>) but DeploymentOptions are provided to configure the
deployment. |
void |
deployVerticle(Verticle verticle,
Handler<AsyncResult<String>> completionHandler)
Like
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>) but the completionHandler will be notified when the deployment is complete. |
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> Future<T> |
executeBlocking(Callable<T> blockingCodeHandler)
|
<T> Future<T> |
executeBlocking(Callable<T> blockingCodeHandler,
boolean ordered)
Safely execute some blocking code.
|
<T> void |
executeBlocking(Handler<Promise<T>> blockingCodeHandler)
Deprecated.
|
<T> void |
executeBlocking(Handler<Promise<T>> blockingCodeHandler,
boolean ordered)
Deprecated.
|
<T> void |
executeBlocking(Handler<Promise<T>> blockingCodeHandler,
boolean ordered,
Handler<AsyncResult<T>> resultHandler)
Deprecated.
|
<T> void |
executeBlocking(Handler<Promise<T>> blockingCodeHandler,
Handler<AsyncResult<T>> resultHandler)
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() |
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.
|
Single<Void> |
rxClose()
Like
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) 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, io.vertx.core.Handler<io.vertx.core.AsyncResult<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, io.vertx.core.Handler<io.vertx.core.AsyncResult<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, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>) but Verticle instance is created by
invoking the verticleSupplier . |
Single<String> |
rxDeployVerticle(Verticle verticle)
Like
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<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, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>) but DeploymentOptions are provided to configure the
deployment. |
<T> Single<T> |
rxExecuteBlocking(Handler<Promise<T>> blockingCodeHandler)
Deprecated.
|
<T> Single<T> |
rxExecuteBlocking(Handler<Promise<T>> blockingCodeHandler,
boolean ordered)
Deprecated.
|
Single<Void> |
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.
|
TimeoutStream |
timerStream(long delay)
Deprecated.
|
String |
toString() |
Throwable |
unavailableNativeTransportCause() |
void |
undeploy(String deploymentID)
Like
#undeploy(String) but the completionHandler will be notified when the undeployment is complete. |
void |
undeploy(String deploymentID,
Handler<AsyncResult<Void>> completionHandler)
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 Vertx vertx()
public static Vertx vertx(VertxOptions options)
options
- the options to usepublic static void clusteredVertx(VertxOptions options, Handler<AsyncResult<Vertx>> resultHandler)
The instance is created asynchronously and the resultHandler is called with the result when it is ready.
options
- the options to useresultHandler
- the result handler that will receive the resultpublic static void 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 HttpClient createHttpClient(HttpClientOptions options)
options
- the 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 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 void close(Handler<AsyncResult<Void>> completionHandler)
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but the completionHandler will be called when the close is completecompletionHandler
- The handler will be notified when the close is complete.public void close()
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but the completionHandler will be called when the close is completepublic Single<Void> rxClose()
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but the completionHandler will be called when the close is completepublic void deployVerticle(String name, Handler<AsyncResult<String>> completionHandler)
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<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 identifiercompletionHandler
- a handler which will be notified when the deployment is completepublic void deployVerticle(String name)
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<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, io.vertx.core.Handler<io.vertx.core.AsyncResult<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 void deployVerticle(String name, DeploymentOptions options, Handler<AsyncResult<String>> completionHandler)
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>)
but DeploymentOptions
are provided to configure the
deployment.name
- the nameoptions
- the deployment options.completionHandler
- a handler which will be notified when the deployment is completepublic void deployVerticle(String name, DeploymentOptions options)
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<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, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>)
but DeploymentOptions
are provided to configure the
deployment.name
- the nameoptions
- the deployment options.public void undeploy(String deploymentID, Handler<AsyncResult<Void>> completionHandler)
#undeploy(String)
but the completionHandler will be notified when the undeployment is complete.deploymentID
- the deployment IDcompletionHandler
- a handler which will be notified when the undeployment is completepublic void undeploy(String deploymentID)
#undeploy(String)
but the completionHandler will be notified when the undeployment is complete.deploymentID
- the deployment IDpublic Single<Void> 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> void executeBlocking(Handler<Promise<T>> blockingCodeHandler, boolean ordered, Handler<AsyncResult<T>> resultHandler)
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 guaranteesresultHandler
- handler that will be called when the blocking code is complete@Deprecated public <T> void 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> Single<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> void executeBlocking(Handler<Promise<T>> blockingCodeHandler, Handler<AsyncResult<T>> resultHandler)
executeBlocking(io.vertx.core.Handler<io.vertx.rxjava.core.Promise<T>>, boolean, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)
called with ordered = true.blockingCodeHandler
- resultHandler
- @Deprecated public <T> void executeBlocking(Handler<Promise<T>> blockingCodeHandler)
executeBlocking(io.vertx.core.Handler<io.vertx.rxjava.core.Promise<T>>, boolean, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)
called with ordered = true.blockingCodeHandler
- @Deprecated public <T> Single<T> rxExecuteBlocking(Handler<Promise<T>> blockingCodeHandler)
executeBlocking(io.vertx.core.Handler<io.vertx.rxjava.core.Promise<T>>, boolean, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)
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 void deployVerticle(Verticle verticle, Handler<AsyncResult<String>> completionHandler)
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<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 deploycompletionHandler
- a handler which will be notified when the deployment is completepublic void deployVerticle(Verticle verticle)
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<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, io.vertx.core.Handler<io.vertx.core.AsyncResult<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 void deployVerticle(Verticle verticle, DeploymentOptions options, Handler<AsyncResult<String>> completionHandler)
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>)
but DeploymentOptions
are provided to configure the
deployment.verticle
- the verticle instance to deployoptions
- the deployment options.completionHandler
- a handler which will be notified when the deployment is completepublic void deployVerticle(Verticle verticle, DeploymentOptions options)
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<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, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>)
but DeploymentOptions
are provided to configure the
deployment.verticle
- the verticle instance to deployoptions
- the deployment options.public void deployVerticle(java.util.function.Supplier<Verticle> verticleSupplier, DeploymentOptions options, Handler<AsyncResult<String>> completionHandler)
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<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
- completionHandler
- public void deployVerticle(java.util.function.Supplier<Verticle> verticleSupplier, DeploymentOptions options)
deployVerticle(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<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, io.vertx.core.Handler<io.vertx.core.AsyncResult<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> Future<T> executeBlocking(Callable<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.
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 guaranteespublic <T> Future<T> executeBlocking(Callable<T> blockingCodeHandler)
executeBlocking(io.vertx.core.Handler<io.vertx.rxjava.core.Promise<T>>, boolean, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)
called with ordered = true.blockingCodeHandler
- @Deprecated public EventLoopGroup nettyEventLoopGroup()
Copyright © 2024 Eclipse. All rights reserved.