Class MllpServer

java.lang.Object
com.framed.interop.hl7.mllp.MllpServer
All Implemented Interfaces:
Closeable, AutoCloseable

public final class MllpServer extends Object implements Closeable
MLLP server (the message responder): listens for connections, reads each framed HL7 message and replies with the acknowledgement produced by the supplied handler.

Each connection is serviced on its own thread and may carry multiple messages. The accept loop runs on a daemon thread started in the constructor.

  • Constructor Details

    • MllpServer

      public MllpServer(int port, UnaryOperator<String> handler) throws IOException
      Binds and starts accepting connections immediately.
      Parameters:
      port - the port to bind (0 for an ephemeral port; see getPort())
      handler - maps a received HL7 message to the acknowledgement to send back
      Throws:
      IOException - if the socket cannot be bound
  • Method Details

    • getPort

      public int getPort()
      Returns:
      the actual bound port (useful when constructed with port 0).
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable