Class PipeEndpointListener

java.lang.Object
org.apache.synapse.transport.pipe.PipeEndpointListener
All Implemented Interfaces:
Runnable

public class PipeEndpointListener extends Object implements Runnable
Runnable that reads messages from a given UNIX pipe.

The pipe will be opened in read/write mode. There are several reasons to do this:

  • Opening a pipe in read only mode blocks until the other end of the pipe is opened for writing (see man 7 fifo). Since there is no way to cleanly stop a thread blocking in the constructor of FileInputStream we open the pipe in read/write mode to avoid blocking.
  • A pipe opened in read only mode will be closed when the other end is closed. By opening the pipe in read/write mode we avoid this. If we unexpectedly receive an end-of-file, we shut down the listener. This avoids unexpected behavior if the file system object is not a pipe (there is no reliable way in Java to determine this).
  • Read operations on the pipe are blocking. By opening the pipe in read/write mode we have a simple way to wake up the listener thread to shut it down cleanly. However, since read/write operations on a file channel can't be invoked concurrently from different threads, we need to create two separate channels from the same file descriptor.
  • Constructor Details

    • PipeEndpointListener

      public PipeEndpointListener(PipeEndpoint endpoint, org.apache.axis2.transport.base.datagram.DatagramDispatcherCallback callback) throws IOException
      Throws:
      IOException
  • Method Details