JDG basically is built on top of JGroups is a toolkit for messaging and is based on protocols. Bela Ban developed it for his post-doc at Cornell University, as he explains on the manual, is a pure java implementation of group communication transport that ended up being used by JBoss (the company).


What is it?

JGroups is a Java library for reliable group communication.

It consists of 3 parts: (1) a socket-like API for application development, (2) a protocol stack, which implements reliable communication, and (3) a set of building blocks, which give the developer high-level abstractions (e.g. ReplicatedHashMap, an implementation of java.util.Map).

Relation to Infinispan

Infinispan <uses> JGroups as its underlying clustering layer. In order to configure the finer details of clustering (discovery, flow control, cross-site, etc) you have to provide a separate XML file with the desired configuration and reference it from your Infinispan XML file as follows – that will have the protocols (which every message will pass through):


<UDP mcast_port=”${jgroups.udp.mcast_port:45588}”


<PING />
<MERGE3 max_interval=”30000″ min_interval=”10000″/>
<VERIFY_SUSPECT timeout=”1500″ />
<pbcast.NAKACK2 xmit_interval=”1000″/>
<UNICAST3 xmit_interval=”1000″/>
<pbcast.STABLE 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” />

Sample Code

      JChannel channel=new JChannel("/home/bela/udp.xml");
      channel.setReceiver(new ReceiverAdapter() {
          public void receive(Message msg) {
              System.out.println("received msg from " + msg.getSrc() + ": " + msg.getObject());
      channel.send(new ObjectMessageSerializable(null, "hello world"));

JGroup and JChannel

While a group is a cluster, a JChannel a is the mean to the members to communicate as well as the building blocks, which are an abstraction above the JChannel. Finally the XML will contain a protocol stack, which has the bi-directional message path, from the building blocks up to the network.


   [fdemeloj@fdemeloj Downloads]$ /home/fdemeloj/Downloads/jdk-11.0.1/bin/java -jar jgroups-5.0.0.Alpha6.jar
Version: 5.0.0.Alpha6 (Stelvio)

 /home/fdemeloj/Downloads/jdk-11.0.1/bin/java -cp jgroups-5.0.0.Alpha6.jar org.jgroups.demos.Draw



[fdemeloj@fdemeloj jgroups]$ /home/fdemeloj/Downloads/jdk-11.0.1/bin/java -cp jgroups-5.0.0.Alpha6.jar org.jgroups.demos.Draw -help

Draw [-help] [-no_channel] [-props <protocol stack definition>] [-clustername <name>] [-state] [-timeout <state timeout>] [-use_unicasts] [-jmx <true | false>] [-name <logical name>] [-send_own_state_on_merge true|false] [-uuid <UUID>]
no_channel: doesn’t use JGroups at all, any drawing will be relected on the whiteboard directly
props: argument can be an old-style protocol stack specification, or it can be a URL. In the latter case, the protocol specification will be read from the URL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s