A collection of utilities for Vert.x which allow for simplified deployment, standardized logging, rescheduling of handlers, and a file based health check handler.
Provides the ability to execute a handler on a timer and reschedule on completion.
RescheduleHandler rescheduleHandler = new RescheduleHandler(vertx, event -> { }, 1000);
vertx.setTimer(1000, rescheduleHandler);
Used to deploy a configurable number of instances of different verticles and enforce dependencies between the verticles.
The number of instances may be specified as a multiple per core by suffixing the value with "C" (e.g. "instances":"2C"
is two instances per core).
The configuration also allows you to optionally register one or more MessageCodec
implementations by specifying an
array of fully qualified class names. Each MessageCodec
class is required to have a no-args public constructor.
Example mainConf.json:
{
"verticles": {
"MetricsVerticle": {
"class": "com.groupon.vertx.utils.MetricsVerticle",
"instances": 1,
"worker": true,
"config": { }
},
"ExampleVerticle": {
"class": "com.groupon.example.verticle.ExampleVerticle",
"instances": 1,
"worker": true,
"config": { },
"dependencies": [ "MetricsVerticle" ]
}
},
"messageCodecs": [
"com.groupon.example.vertx.MyMessageCodec"
]
}
Example mod.json:
{
"main": "com.groupon.vertx.utils.MainVerticle",
"preserve-cwd": true,
"worker": false
}
Starting Vert.x with MainVerticle
java -cp conf:lib/* org.vertx.java.platform.impl.cli.Starter runmod com.groupon.example~release -instances 1 -conf conf/mainConf.json
A wrapper to provide standardized logging calls using slf4j and the com.arpnetworking.logback.StenoMarker
Logger log = Logger.getLogger(Example.class);
log.info("sampleMethod", "Hello logging world!");
In the MainVerticle's configuration each child verticle's config key is either an inline JSON object or a String representing a file path. If you specify a file path you may also specify a custom parser with the system property vertx-utils.config-parser-class-name (e.g. -Dvertx-utils.config-parser-class-name=com.example.MyParser). This parser receives the file contents and is required to return a Vert.x JsonObject. Use it to translate your preferred configuration (e.g. hocon, properties, yaml, xml, etc.) into JSON.
Prerequisites:
Building:
vertx-utils> mvn verify
To use the local version you must first install it locally:
vertx-utils> mvn install
You can determine the version of the local build from the pom file. Using the local version is intended only for testing or development.
Published under Apache Software License 2.0, see LICENSE
© Groupon Inc., 2015