About JIPC

JIPC is library providing interprocess synchronization and communication capabilities for Java processes running in different JVMs at different computers. JIPC provides wide set of standard primitives: semaphore, event, FIFO queue, barrier, shared memory, shared and exclusive locks.

Structure of JIPC package

JIPC package consists of four subpackages:

org.garret.jipc
Defines abstract API for JIPC session and synchronization primitives
org.garret.jipc.client
Provides stubs of JIPC primitives sending requests to the serve
org.garret.jipc.server
Server implementation of JIPC primitives
org.garret.jipc.protocol
Client-server communication protocol

JIPC supports local and remote sessions. Remote sessions created by org.garret.jipc.client.JIPCClientFactory class establish connection with the server through TCP/IP stream socket. Server process should be started before clients. In this case primitives at local computer servers as stubs and redirect requests to the server. This mode is useful to provide synchronization and communication between several Java processes at the same or different computers.

Local sessions are created by org.garret.jipc.server.JIPCServer class. Them are useful to provide synchronization of threads within the same process (if you want to use more sophisticated synchronization primitives than standard synchronization facilities provided by Java language). The single local session can be shared by all threads. No server process should be started in this case.

Quick start

The package jipc.jar is located in lib directory. If you want to build it yourself, go to src directory and execute compile.bat script.

Add jipc.jar to your Java class path. Server can be started by the following command:

     java org.garret.jipc.server.JIPCServer PORT
Here PORT is any free IP port at your system. Server is starts interactive dialog, allowing you the inspect current state of the server (info command) or terminate the server (exit command).

The following system properties are used by server:

PropertyMeaningDefault value
jipc.lingerSocket linger time10 seconds
jipc.debugDebug level:
  • 0 no debugging
  • 1 trace all exceptions
  • 2 trace session open/close requests
  • 3 trace all requests
1

It is possible to start server in daemon mode, without interactive dialog. It can be done with "-d" option. For example, at Windows the following command:
     start java org.garret.jipc.server.JIPCServer -d 6000
will start server process in the background. To send commands to the server started in daemon mode you can use org.garret.jipc.client.JIPCServerMonitor:
   Usage: 
       java org.garret.jipc.client.JIPCServerMonitor HOSTNAME PORT [command]
   Commands:
       SHUTDOWN            shutdown server
       INFO                dump information about server status
If command is not specified in command line, server monitor starts interactive dialog. In this dialog, except SHTDOWN and INFO commands it also supports EXIT and HELP commands. EXIT command is used to close dialog, HELP shows list of available commands. Now it is possible to start client processes using JIPC library. Client should create JIPC sessions using org.garret.jipc.client.JIPCClientFactory.create(String address, int port) method. Here address is address of the host where server is started and port is port listening by the server. Before exit client should close session. Below is example of using JIPC library:
import org.garret.jipc.*;
import org.garret.jipc.client.JIPCClientFactory;

public class JIPCTest { 
    public static void main(String args[]) throws Exception { 
        String hostName = System.getProperty("host", "localhost");
	int    port = Integer.parseInt(System.getProperty("port", "6000"));

        JIPCFactory factory = org.garret.jipc.client.JIPCClientFactory.getInstance();
        JIPCSession session = factory.create(host, port);

	JIPCMutex   mutex = session.createMutex("my-mutex", false);
	mutex.lock();
	// do something
	mutex.unlock();

	session.close();
    }
}

Distribution terms

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR OF THIS SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

I will provide e-mail support and help you with development of JIPC package.


Look for new version at my homepage | E-Mail me about bugs and problems