Currently working with 2 different systems.
On System 1, JGroups is working as expected.
On System 2, JGroups does appear to be talking with the application.
Both systems have 2 machines in the configuration.
On the working system, as soon as the 2nd machine starts up and joins the group via the setName() routine, the 1st machine receives a callback to the viewAccepted() routine and the "Received message from JGroups" is printed out.
On the failing system, the message "Received message from JGroups" is never printed out. No errors are received. It seems as though JGroups either never sends the message or it did send the message but it was never received.
As a test, a very stripped down, basic JGroup program was written and it exhibits the same behavior as the actual program where viewAccepted() is never entered.
Both systems are using 4.1.2 version of the JGroups JAR file and executing the cksum command confirms the file is the same on all systems.
There appears to be some environment/system configuration constraint which needs to be changed but not idea which as JGroups is very new to me.
Here is the main program.
import java.net.InetAddress;
import org.jgroups.*;
import org.jgroups.blocks.MessageDispatcher;
import org.jgroups.blocks.GroupRequest;
import org.jgroups.blocks.RequestOptions;
import org.jgroups.blocks.ResponseMode;
import org.jgroups.util.RspList;
public class JGroupsMain
{
private static JChannel myChannel;
private static JChannel myChannelCast;
private static JChannel myActiveChannel;
private static MyPeerListener myListener;
private static MessageDispatcher messageDispatcherPrimary;
private static InetAddress primaryAddress;
public static void main(String [] args)
{
System.out.println("Initializing" );
try
{
myChannel = new JChannel("jgroups.xml");
myChannelCast = new JChannel("jgroups.xml");
myListener = new MyPeerListener( 0 );
myChannel.setReceiver(myListener);
messageDispatcherPrimary = new MessageDispatcher(myChannelCast, myListener);
int currentActiveNetwork = 0;
boolean isPrimaryReady = true;
setmyActiveChannel( myChannel );
setCurrentMessageDispatcher( messageDispatcherPrimary );
primaryAddress = InetAddress.getByName( args[1] );
myChannel.setDiscardOwnMessages(true);
myChannelCast.setDiscardOwnMessages(true);
String nodeName = args[0];
if (nodeName != null)
{
myChannel.setName(nodeName);
myChannelCast.setName(nodeName);
}
String clusterName = "MY_CLUSTER";
myChannel.connect( clusterName );
myChannelCast.connect( clusterName + "-SYNC" );
}
catch ( IllegalStateException ce )
{
System.out.println("Illegal State Exception : " + ce );
}
catch (Exception e)
{
System.out.println("Exception : " + e );
}
}
private static void setmyActiveChannel(JChannel myChannel2)
{
myActiveChannel = myChannel2;
}
private static void setCurrentMessageDispatcher(MessageDispatcher messageDispatcher)
{
MessageDispatcher currentMessageDispatcher = messageDispatcher;
}
}
The following is the Listener class.
import org.jgroups.*;
public class MyPeerListener extends org.jgroups.ReceiverAdapter implements org.jgroups.blocks.RequestHandler
{
int assignedLANListener = -1;
public MyPeerListener(int assignedLAN)
{
assignedLANListener = assignedLAN;
}
@Override
public Object handle(Message arg0) throws Exception {
return null;
}
public void viewAccepted(org.jgroups.View view)
{
System.out.println("Received message from JGroups");
}
}
After compiling, execute by passing in the machine name and IP.
On machine 1, pass in the machine name and IP.
> java JGroupsMain machine1 111.111.111.111
On machine 2, pass in the machine name and IP.
> java JGroupsMain machine2 111.111.111.222
To be sure it wasn't anything in the XML file, I copied the XML file from the working system to the failing system and changed its machine names, but that didn't help.
netstat does show it opens the port.
Any recommendations what to check on the system to determine why JGroups may not be talking with the application.
Could something be blocked?