Skip to content

Configuration Guide

Lin Gao edited this page Dec 2, 2024 · 7 revisions

When the vertx layer is installed to the WildFly server, there will be a vertx subsystem available to configure.

For more information on the installation, please refer to Installation-Guide

Activate vertx subsystem

If you see the following errors when trying to read resource information from vertx subsystem:

[standalone@localhost:9990 /] /subsystem=vertx:read-resource()
{
    "outcome" => "failed",
    "failure-description" => "WFLYCTL0030: No resource definition is registered for address [(\"subsystem\" => \"vertx\")]",
    "rolled-back" => true
}

You need to activate the vertx subsystem using the following CLI:

Activate Vertx Subsystem CLI
if (outcome != success) of /subsystem=vertx:read-resource
  echo INFO: Adding vertx subsystem.
  /extension=org.wildfly.extension.vertx:add
  /subsystem=vertx:add
  :reload
else
  echo INFO: vertx subsystem already in configuration, subsystem not added.
end-if

Then you can see the basic vertx subsystem information:

[standalone@localhost:9990 /] /subsystem=vertx:read-resource()
{
    "outcome" => "success",
    "result" => {
        "address-resolver-option" => undefined,
        "vertx" => undefined,
        "vertx-option" => undefined,
        "vertx-option-file" => undefined
    }
}

Configure vertx subsystem

There is no vertx instance available from vertx subsystem by default, you can run the following CLI to set it up if you want the default VertxOptions to be used:

[standalone@localhost:9990 /] /subsystem=vertx/vertx=vertx:add()
{"outcome" => "success"}

Or you can define some vertx options first.

Configure vertx option

VertxOptions can be configured under /subsystem=vertx/vertx-option management resource, like:

[standalone@localhost:9990 /] /subsystem=vertx/vertx-option=vo:add(event-loop-pool-size=20, max-eventloop-execute-time=5, max-eventloop-execute-time-unit=SECONDS)
{"outcome" => "success"}

With above CLI, you configured a VertxOptions named vo with eventLoopPoolSize=20 and maxEventLoopExecuteTime to 5 seconds. Now you can read the resource information:

[standalone@localhost:9990 /] /subsystem=vertx/vertx-option=vo:read-resource
{
    "outcome" => "success",
    "result" => {
        "address-resolver-option" => undefined,
        "blocked-thread-check-interval" => undefined,
        "blocked-thread-check-interval-unit" => undefined,
        "classpath-resolving-enabled" => undefined,
        "event-loop-pool-size" => 20,
        "file-cache-enabled" => undefined,
        "internal-blocking-pool-size" => undefined,
        "max-eventloop-execute-time" => 5L,
        "max-eventloop-execute-time-unit" => "SECONDS",
        "max-worker-execute-time" => undefined,
        "max-worker-execute-time-unit" => undefined,
        "prefer-native-transport" => undefined,
        "warning-exception-time" => undefined,
        "warning-exception-time-unit" => undefined,
        "worker-pool-size" => undefined
    }
}

You can update an attribute, like:

[standalone@localhost:9990 /] /subsystem=vertx/vertx-option=vo:write-attribute(name=worker-pool-size,value=50)
{"outcome" => "success"}

If the vertx-option(vo in above case) is not referred by the vertx instance, it won’t update server state, otherwise, you need to run :reload.

For more information of the attributes in /subsystem=vertx/vertx-option management resource, please run:

/subsystem=vertx/vertx-option=vo:read-resource-description()

most of the attributes correspond to the primitive type fields in VertxOptions.

The attribute of address-resolver-option refers to /subsystem=vertx/address-resolver-option management resource name where the AddressResolverOptions is configured, please see Configure address resolver option section below.

Configure address resolver option

AddressResolverOptions is mainly used by the HostnameResolver in Vertx to do DNS lookup. You can configure it using CLI like:

[standalone@localhost:9990 /] /subsystem=vertx/address-resolver-option=aro:add(query-time-out=10000)
{"outcome" => "success"}

With above CLI, you configured an AddressResolverOptions named aro with queryTimeout set to 10 seconds. Then you can read the source using CLI:

[standalone@localhost:9990 /] /subsystem=vertx/address-resolver-option=aro:read-resource
{
    "outcome" => "success",
    "result" => {
        "cache-max-time-to-live" => undefined,
        "cache-min-time-to-live" => undefined,
        "cache-negative-time-to-live" => undefined,
        "hosts-value" => undefined,
        "max-queries" => undefined,
        "n-dots" => undefined,
        "opt-resource-enabled" => undefined,
        "query-time-out" => 10000L,
        "rd-flag" => undefined,
        "rotate-servers" => undefined,
        "round-robin-inet-address" => undefined,
        "search-domains" => undefined,
        "servers" => undefined
    }
}

For more information about the attributes, you can run:

/subsystem=vertx/address-resolver-option=aro:read-resource-description()

Set up vertx instance

When you configured some VertxOptions, you can set up the vertx instance with the option-name attribute:

[standalone@localhost:9990 /] /subsystem=vertx/vertx=vertx:add(option-name=vo)
{"outcome" => "success"}

or update the option-name if the vertx instance was already set up:

[standalone@localhost:9990 /] /subsystem=vertx/vertx=vertx:write-attribute(name=option-name,value=vof)
{
    "outcome" => "success",
    "response-headers" => {
        "operation-requires-reload" => true,
        "process-state" => "reload-required"
    }
}

[standalone@localhost:9990 /] :reload
{
    "outcome" => "success",
    "result" => undefined
}
Note
Either resource name of /subsystem=vertx/vertx-option or /subsystem=vertx/vertx-option-file can be used as the option-name in the vertx instance.

Now, the vertx instance is setup, it is exposed to the CDI container with a qualifier: io.smallrye.common.annotation.Identifier.Literal.of("vertx") for consumption.