Skip to main content

This is a cluster manager implementation for Vert.x that uses JGroups.

In Vert.x a cluster manager is used for various functions including:

  • Discovery and group membership of Vert.x nodes in a cluster

  • Maintaining cluster wide topic subscriber lists (so we know which nodes are interested in which event bus addresses)

  • Distributed Map support

  • Distributed Locks

  • Distributed Counters

Cluster managers do not handle the event bus inter-node transport, this is done directly by Vert.x with TCP connections.

Using this cluster manager

To use the the cluster manager, add the following dependency to the dependencies section of your build descriptor:

  • Maven (in your pom.xml):

  • Gradle (in your build.gradle file):

compile 'io.vertx:vertx-jgroups:3.3.3'

If you are using Vert.x from the command line, the jar corresponding to this cluster manager (it will be named vertx-jgroups-3.3.3.jar should be in the lib directory of the Vert.x installation. Don’t forget to also add the jgroups jar too (org.jgroups:jgroups:jar).

If the jar is on your classpath as above then Vert.x will automatically detect this and use it as the cluster manager. Please make sure you don’t have any other cluster managers on your classpath or Vert.x might choose the wrong one. You can also specify it using the following system property: -Dvertx.clusterManagerFactory=io.vertx.spi.cluster.jgroups.JGroupsClusterManager

You can also specify the cluster manager programmatically if you are embedding Vert.x by specifying it on the options when you are creating your Vert.x instance, for example:

ClusterManager mgr = new JGroupsClusterManager();
VertxOptions options = new VertxOptions().setClusterManager(mgr);
Vertx.clusteredVertx(options, res -> {
  if (res.succeeded()) {
    Vertx vertx = res.result();
  } else {
    // failed!

Configuring this cluster manager

Usually the cluster manager is configured by a file:

<config xmlns:xsi=""





<MERGE3 max_interval="30000" min_interval="10000"/>
<VERIFY_SUSPECT timeout="1500"/>
<pbcast.NAKACK2 xmit_interval="500"
<UNICAST3 xmit_table_num_rows="100" xmit_table_msgs_per_row="1000" xmit_table_max_compaction_time="30000" max_msg_batch_size="500"/>
<pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
<pbcast.GMS print_local_addr="true" join_timeout="2000"
<UFC max_credits="2M"min_threshold="0.4"/>
<MFC max_credits="2M" min_threshold="0.4"/>
<FRAG2 frag_size="60K"/>

<CENTRAL_LOCK use_thread_id_for_lock_owner="false"/>

This file is packaged in the JGroup cluster Manager jar file.

If you want to override this configuration you can provide a file called jgroups.xml on your classpath and this will be used instead.

The xml file is a JGroups configuration file and is described in detail in the documentation on the JGroups web-site.

JGroups supports several different transports including multicast and TCP. The default configuration uses multicast so you must have multicast enabled on your network for this to work.

For full documentation on how to configure the transport differently or use a different transport please consult the JGroups documentation.

Trouble shooting clustering

If the default multicast configuration is not working here are some common causes:

Multicast not enabled on the machine.

When using UDP, IP multicasting is required, on some systems, multicast route(s) need to be added to the routing table otherwise, the default route will be used

Note that some systems don’t consult the routing table for IP multicast routing, only for unicast routing

MacOS example:

# Adds a multicast route for
sudo route add -net

# Adds a multicast route for
sudo route add -net

Please google for more information.

Using IPv6 without a correctly configured routing table

Running in IPv6 without a correctly configured IPv6 routing table

By default, the JVM uses IPv6, but the routing table is not configured correctly, or the config uses IPv4 Solution: look at IPv6 routing or force use of IPv4 ( More details about this are available on

Using wrong network interface

If you have more than one network interface on your machine (and this can also be the case if you are running VPN software on your machine), then JGroups may be using the wrong one.

Java parameter jgroups.bind_addr determines the network interface to bind to, e.g. jgroups.bind_addr=

The following values are also recognized:

  • global: picks a global IP address if available. If not, falls back to a site-local IP address

  • site_local: picks a site local (non routable) IP address, e.g. from the or address range.

  • link_local: picks a link-local IP address, from through

  • non_loopback: picks any non loopback address.

  • loopback: picks a loopback address, e.g.

  • match-interface: picks an address which matches a pattern against the interface name, e.g. match-interface:eth.\*

  • match-host: picks an address which matches a pattern against the host name, e.g. match-host:linux.\*

  • match-address: picks an address which matches a pattern against the host address, e.g. match-address:192.168.\*

When running Vert.x is in clustered mode, you should also make sure that Vert.x knows about the correct interface. When running at the command line this is done by specifying the cluster-host option:

vertx run myverticle.js -cluster -cluster-host your-ip-address

Where your-ip-address is the same IP address you specified in the JGroups configuration.

If using Vert.x programmatically you can specify this using setClusterHost.

Using a VPN

This is a variation of the above case. VPN software often works by creating a virtual network interface which often doesn’t support multicast. If you have a VPN running and you do not specify the correct interface to use in both the jgroups configuration and to Vert.x then the VPN interface may be chosen instead of the correct interface.

So, if you have a VPN running you may have to configure both the JGroups and Vert.x to use the correct interface as described in the previous section.

When multicast is not available

In some cases you may not be able to use multicast as it might not be available in your environment. In that case you should configure another transport, e.g. TCP to use TCP sockets, or AWS when running on Amazon EC2.

For more information on available JGroups transports and how to configure them please consult the JGroups documentation.

Enabling logging

When trouble-shooting clustering issues with JGroups it’s often useful to get some logging output from JGroups to see if it’s forming a cluster properly. You can do this (when using the default JUL logging) by adding a file called on your classpath. This is a standard java.util.loging (JUL) configuration file. Inside it set:


and also


Using your own instance of JChannel

You can instantiate JGroupsClusterManager with your own instance of JChannel:

ClusterManager mgr = new JGroupsClusterManager(channel);
VertxOptions options = new VertxOptions().setClusterManager(mgr);
Vertx.clusteredVertx(options, res -> {
  if (res.succeeded()) {
    Vertx vertx = res.result();
  } else {
    // failed!