swingglassfishejbjms2phase-commit

Implement two phase commit protocol between EJB Application(Running on Glassfish) and Swing application


I have a EJB application running on Glassfish server which stores data on MySQL DB which I call as Global DB. I have two exact remote Swing applications which are stand alone applications accessing EJB's using RMI. They have their own local DB in case of lost connection.

My aim is to implement two phase commit protocol i.e to make one participant as coordinator and others as participants.

One method which I could think of was to implement using JMS i.e send a message across queue and make remote clients listen to these messages and take appropriate action. I do this my sending a message on Buttonclick of one of the Swing application. Problem is, even tough I have implemented MessageListener, onMessage() method does not receive any message for the other client.

Each Remote client has following properties set:

 props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
 props.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
 props.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
 props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
 props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");

This is to connect to Glassfish server and access the connectionFactory and Queue which I have already configured.

Is it because only application running on server are allowed to receive messages and not remote applications?

Any suggestions for topology for 2 PC are welcome.


Solution

  • For this, we used JMS for exchanging the messages between these systems i.e one acting as coordinator who will initiate the process by sending message on the queue and others will respond accordingly by sending back again a message on the queue.