RocksWorker.

Let’s add a new Maven module and create a package and add several classes. We will need several new class and one configuration file:

RocksService interface and implementation — this is the definition of our future service;

RocksServiceVerticle — we have to deploy the service, we can do this via a verticle

Package-info.java — configuration file that defines auto-generation settings for two new useful classes, that Vert.x will create for us.

New Maven module.

One more thing, to the global Maven configuration file, let’s add 3 new dependencies.

vertx-service-proxy — this one creates a proxy for us. A proxy allows giving access to the isolated functionality from the outside world;

vertx-codegen — this dependency adds a possibility to generate tons of boilerplate code just with a couple of annotations;

vertx-hazelcast — this dependency creates a cluster for us.

New dependencies.

Let’s add cluster settings to the common package. This is an XML file in the resources directory. We will not go deep inside cluster settings today, please refer to Vert.x documentation to know more about Hazelcast and cluster.xml.

cluster.xml

Let’s take a look at package-info.java file. This file defines settings for boilerplate code generation. Here we say that module rocksworker contains classes to be generated.

Information for a boilerplate generator.

Let’s define RocksService interface. The interface is straightforward. We define two string constants — the name and the address on event bus of our service. Also, we want to define two asynchronous methods to get and to create a user. Both methods don’t return anything but instead of that act asynchronously via handlers.

RocksService interface.

In the implementation of the interface in both methods, we return futures with placeholder responses. Both objects in responses will be replaced by RocksDB calls in the next article.

RocksService implementation.

To define a verticle extended from our Microservice verticle class, we need to add the Common module as a dependency.

Common module.

Let’s add one more method to the MicroserviceVerticle class. It will be used to publish information about new event bus service into service discovery.