Discover cluster nodes using Probe shell script

Another discovery tool which shipped with JBoss AS 4-5-6 is the shell which invokes a test class contained in JGroups API named org.jgroups.tests.Probe.

This class sends a multicasts a packet to (default multicast address and port) and waits for responses until the timeout has elapsed. Here's how you can adapt it to JBoss AS 7 (warning not tested!)



set CLASSPATH=%JBOSS_HOME%\modules\org\jgroups\main\jgroups-3.0.6.Final.jar


java -cp %CP% org.jgroups.tests.Probe %*

Here's the expected output:

-- send probe on /

#1 (263 bytes): (ClusterGroup)
Version=2.2.9 beta, cvs="$Id:,v 1.23 2006/04/04 17:21:24 
p $"
view: [|1] [|1]
. . . . . . .
Finally, if you want a Quick Servlet for dumping the various programming options displayed in this tutorial:

package com.sample;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.infinispan.manager.CacheContainer;
import org.infinispan.remoting.transport.Address;
import org.infinispan.remoting.transport.jgroups.JGroupsAddress;
import org.jboss.msc.service.ServiceName;

import org.jgroups.Channel;
import org.jgroups.Event;
import org.jgroups.PhysicalAddress;
import org.jgroups.stack.IpAddress;

import java.util.Hashtable;

 * Servlet implementation class TestCluster
public class TestCluster extends HttpServlet {
    private static final long serialVersionUID = 1L;
    private CacheContainer container;

    public TestCluster() {
        // TODO Auto-generated constructor stub

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try {
        } catch (Exception e) {
            // TODO Auto-generated catch block
    public Collection<IpAddress> getClusterMembersJGroups(HttpServletResponse response) {
        PrintWriter out = response.getWriter();
        Channel channel = (Channel) CurrentServiceContainer.getServiceContainer().getService(ServiceName.JBOSS.append("jgroups", "channel", "web")).getValue();

        List<org.jgroups.Address> members = channel.getView().getMembers();
        List< IpAddress> addresses = new ArrayList< IpAddress>();
        for (org.jgroups.Address member: members) {
            PhysicalAddress physicalAddr = (PhysicalAddress)channel.down(new Event(Event.GET_PHYSICAL_ADDRESS, member));
            IpAddress ipAddr = ( IpAddress)physicalAddr;
            out.println("Found IP: "+ipAddr.getIpAddress().getHostAddress());
        return addresses;

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    public Collection<org.infinispan.remoting.transport.Address> getClusterMembersInfinispan(HttpServletResponse response) {
        PrintWriter out = response.getWriter();
        List<org.infinispan.remoting.transport.Address> members = container.getCache().getCacheManager().getMembers();
        for (org.infinispan.remoting.transport.Address member: members) {
            out.println("Found Member:" +member.toString());
        return members;

    public void getClusterMembersJMX(HttpServletResponse response) throws Exception {
        PrintWriter out = response.getWriter();
        Object obj = ManagementFactory.getPlatformMBeanServer().getAttribute(ObjectName.getInstance("jgroups:type=channel,cluster=\"web\""), "View");

Just keep in mind that when deploying your Servlet, you need to trigger some dependencies like the JBoss AS core modules, the Infinispan API and JGroups API.

Dependencies:,org.jgroups,org.infinispan export                         

Related articles available on

JBoss Clustering a Web Application

Please Note: This article cover JBoss AS 4/5/6 releases. If you w

Clustering EJB 3 with JBoss AS

To cluster a stateless session bean in EJB 3 all you need to do i

JBoss monitoring HTTP Session replication

In this article we'll show how to monitor HTTPSession replication

How do I change multicast address of JBoss cluster ?

Since JBoss AS 4.0.3, the jboss.partition.udpGroup property can b

JBoss farming service

What is the farming service ? this article explains about it, als

JBoss HTTP Session replication

HTTP session replication is used to replicate the state associate