Class MllpClient

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

public final class MllpClient extends Object implements Closeable
MLLP client (the message initiator): connects to a remote MLLP endpoint, sends a framed HL7 message and reads back the framed acknowledgement.

The connection is opened lazily and reused; on any I/O error it is dropped so the next call reconnects. Instances are synchronised so a single client can be shared across threads.

  • Constructor Details

    • MllpClient

      public MllpClient(String host, int port, int timeoutMs)
      Parameters:
      host - target host
      port - target port
      timeoutMs - connect and read timeout in milliseconds
  • Method Details

    • sendAndReceive

      public String sendAndReceive(String message) throws IOException
      Sends an HL7 message and returns the acknowledgement message.
      Parameters:
      message - the HL7 message to send
      Returns:
      the acknowledgement (ACK) message text
      Throws:
      IOException - if the connection fails, times out, or the peer closes before replying
    • close

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