Camel Components

MLLP

Since Camel 2.17

Both producer and consumer are supported

The MLLP component is specifically designed to handle the nuances of the MLLP protocol and provide the functionality required by Healthcare providers to communicate with other systems using the MLLP protocol.

The MLLP component provides a simple configuration URI, automated HL7 acknowledgment generation, and automatic acknowledgment interrogation.

The MLLP protocol does not typically use a large number of concurrent TCP connections - a single active TCP connection is the normal case. Therefore, the MLLP component uses a simple thread-per-connection model based on standard Java Sockets. This keeps the implementation simple and eliminates the dependencies on only Camel itself.

The component supports the following:

  • A Camel consumer using a TCP Server

  • A Camel producer using a TCP Client

The MLLP consumer gives the HL7 payload as a String by default (stringPayload=true), or as a byte[] with stringPayload=false. The MLLP producer sends a String (or another CharSequence) or a byte[] body, with text encoded in the charset of MSH-18, or charsetName (see Character set). Another body, such as an InputStream or a file, is converted to a byte[] with the Camel type converter. A body that cannot be converted fails the exchange with a MllpInvalidMessageException.

Maven users will need to add the following dependency to their pom.xml for this component:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-mllp</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

Configuring Options

Camel components are configured on two separate levels:

  • component level

  • endpoint level

Configuring Component Options

At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.

For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.

Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.

You can configure components using:

  • the Component DSL.

  • in a configuration file (application.properties, *.yaml files, etc).

  • directly in the Java code.

Configuring Endpoint Options

You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.

Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.

A good practice when configuring options is to use Property Placeholders.

Property placeholders provide a few benefits:

  • They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.

  • They allow externalizing the configuration from the code.

  • They help the code to become more flexible and reusable.

The following two sections list all the options, firstly for the component followed by the endpoint.

Component Options

The MLLP component supports the following options which are listed below.

Name Description Default Type

autoAck (common)

Whether the consumer generates the HL7 acknowledgement it sends back: AA when the exchange completes, AE when it fails, or the type set in the CamelMllpAcknowledgementType exchange property. An acknowledgement that the route sets in the CamelMllpAcknowledgement or CamelMllpAcknowledgementString exchange property is sent instead. The CamelMllpAutoAcknowledge exchange property overrides this option for one exchange.

true

boolean

charsetName (common)

The charset of an HL7 message that has no MSH-18. The consumer decodes, and the producer encodes, a message in the charset named in MSH-18 of the message, and in this charset when the message has no MSH-18, or MSH-18 names a charset that is not supported. The CamelCharsetName header and exchange property are not used. The default is the defaultCharset of the component (ISO-8859-1).

String

configuration (common)

Sets the default configuration to use when creating MLLP endpoints.

MllpConfiguration

hl7Headers (common)

Whether the consumer sets the CamelMllp headers from the fields of the MSH segment of the received message, such as CamelMllpMessageType from MSH-9.

true

boolean

requireEndOfData (common)

Whether an MLLP frame must end with END_OF_BLOCK (0x1c) followed by END_OF_DATA (a carriage return, 0x0d), as the MLLP standard specifies. Some systems do not send the final END_OF_DATA byte: disable this option to accept a frame that ends with END_OF_BLOCK. Applies to the messages the consumer receives and the acknowledgements the producer receives.

true

boolean

stringPayload (common)

Whether the consumer sets the body to a String, decoded in the charset named in MSH-18 of the message, or in charsetName when the message has no MSH-18 or MSH-18 names a charset that is not supported. When disabled, the body is the byte array as received, and the CamelCharsetName exchange property holds that charset.

true

boolean

validatePayload (common)

Whether to validate the HL7 payloads received (an MSH segment first, a segment delimiter at the end, no MLLP framing bytes inside). The consumer fails the exchange of an invalid message with an MllpInvalidMessageException. The producer fails the exchange with an MllpInvalidAcknowledgementException when the acknowledgement is invalid or has no MSA segment.

false

boolean

acceptTimeout (consumer)

The SO_TIMEOUT, in milliseconds, of the server socket of the consumer: how long one accept() call waits for a new connection before the consumer checks that it is still running and waits again. It is also how long an idle thread of the consumer is kept.

60000

int

backlog (consumer)

The backlog of the server socket of the consumer: the maximum length of the queue of incoming connections that are not accepted yet. A connection that arrives when the queue is full is refused. A value of 0 or less uses the default of the JVM (50).

5

Integer

bindRetryInterval (consumer)

The time, in milliseconds, the consumer waits between two attempts to bind its server socket to the port (see bindTimeout).

5000

int

bindTimeout (consumer)

How long, in milliseconds, the consumer keeps trying to bind its server socket to the port when it starts. Without lenientBind, the consumer fails to start when the port is not bound within this time.

30000

int

bridgeErrorHandler (consumer)

Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to receive incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. If disabled, the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions by logging them at WARN or ERROR level and ignored.

true

boolean

lenientBind (consumer)

Whether the consumer starts without waiting for its server socket to be bound. When enabled, the consumer binds the port in a background thread, retrying until bindTimeout, and the route starts even when the port is not available yet. When disabled, the consumer fails to start when it cannot bind the port within bindTimeout.

false

boolean

maxConcurrentConsumers (consumer)

The maximum number of client connections the consumer serves at the same time, each in its own thread. A new connection that arrives when this number of connections is active is reset.

5

int

reuseAddress (consumer)

Whether to enable the SO_REUSEADDR socket option, on the server socket of the consumer and on the socket of the producer.

false

Boolean

exchangePattern (consumer (advanced))

The exchange pattern of the endpoint. The consumer always creates InOut exchanges: with autoAck disabled, InOnly sends no acknowledgement when the route sets none, while InOut reports a missing acknowledgement as an error. With InOnly, the producer sends the message without waiting for an acknowledgement.

Enum values:

  • InOnly

  • InOut

InOut

ExchangePattern

connectTimeout (producer)

The timeout, in milliseconds, for the producer to establish the TCP connection. 0 means no timeout.

30000

int

idleTimeoutStrategy (producer)

What the producer does with a connection that has been idle for idleTimeout: RESET sets SO_LINGER to 0 and closes the socket, which resets the connection; CLOSE closes the socket gracefully. The consumer always resets an idle connection.

Enum values:

  • RESET

  • CLOSE

RESET

MllpIdleTimeoutStrategy

keepAlive (producer)

Whether to enable the SO_KEEPALIVE socket option on the TCP connections of the producer and of the consumer.

true

Boolean

lazyStartProducer (producer)

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

tcpNoDelay (producer)

Whether to enable the TCP_NODELAY socket option (which disables Nagle’s algorithm) on the TCP connections of the producer and of the consumer.

true

Boolean

autowiredEnabled (advanced)

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

boolean

defaultCharset (advanced)

The default of the charsetName option of the endpoints: the charset of an HL7 message that has no MSH-18, or whose MSH-18 names a charset that is not supported.

ISO-8859-1

String

logPhi (advanced)

Whether to log PHI (protected health information): the content of the HL7 messages and acknowledgements in log entries and exception messages.

false

Boolean

logPhiMaxBytes (advanced)

The maximum number of bytes of PHI that is logged in a log entry, when logPhi is enabled.

5120

Integer

maxBufferSize (advanced)

Maximum size, in bytes, of the buffer used when receiving or sending data over the wire.

1073741824

int

minBufferSize (advanced)

Minimum size, in bytes, of the buffer used when receiving or sending data over the wire.

2048

int

readTimeout (advanced)

The SO_TIMEOUT, in milliseconds, used once the start of an MLLP frame has been received: how long each further read waits for the rest of the frame. When it expires, the producer fails the exchange with an MllpAcknowledgementTimeoutException, and the consumer resets the connection.

5000

int

receiveBufferSize (advanced)

The SO_RCVBUF socket option, in bytes: the size of the receive buffer of the operating system for the sockets of the producer and of the consumer. The operating system takes it as a hint. A value of 0 or less keeps the default of the operating system.

8192

Integer

receiveTimeout (advanced)

The SO_TIMEOUT, in milliseconds, of the first read of a message: how long the producer waits for the acknowledgement to start arriving, and how long the consumer waits for data on a connection before it checks the idleTimeout and waits again.

15000

int

sendBufferSize (advanced)

The SO_SNDBUF socket option, in bytes: the size of the send buffer of the operating system for the TCP connections of the producer and of the consumer. The operating system takes it as a hint. A value of 0 or less keeps the default of the operating system.

8192

Integer

hostnameVerification (security)

Whether the producer checks that the certificate of the server matches the host it connects to, when SSL/TLS is used. When disabled, any certificate accepted by the trust store is accepted, whatever host it was issued for.

true

boolean

sslContextParameters (security)

Sets the SSLContextParameters for securing TCP connections. If set, the MLLP component will use SSL/TLS for securing both producer and consumer TCP connections. This allows the configuration of trust stores, key stores, protocols, and other SSL/TLS settings. If not set, the MLLP component will use plain TCP communication.

SSLContextParameters

useGlobalSslContextParameters (security)

Whether to use the global SSLContextParameters of the CamelContext for the endpoints that have no sslContextParameters.

false

boolean

idleTimeout (tcp)

The time, in milliseconds, after which a connection with no activity is ended. The producer closes or resets its connection, as set by idleTimeoutStrategy, and opens a new one for the next message. The consumer resets a client connection that has received no message for this time, checked each time the receiveTimeout expires. Not set, or 0 or less, disables the idle timeout.

Integer

Endpoint Options

The MLLP endpoint is configured using URI syntax:

mllp:hostname:port

With the following path and query parameters:

Path Parameters

Name Description Default Type

hostname (common)

Required The host name or IP address. The consumer binds its server socket to it, or to all local addresses when not set (such as mllp:8888). The producer connects to it, or to the local host when not set.

String

port (common)

Required The TCP port: the consumer listens on it, and the producer connects to it.

int

Query Parameters

Name Description Default Type

autoAck (common)

Whether the consumer generates the HL7 acknowledgement it sends back: AA when the exchange completes, AE when it fails, or the type set in the CamelMllpAcknowledgementType exchange property. An acknowledgement that the route sets in the CamelMllpAcknowledgement or CamelMllpAcknowledgementString exchange property is sent instead. The CamelMllpAutoAcknowledge exchange property overrides this option for one exchange.

true

boolean

charsetName (common)

The charset of an HL7 message that has no MSH-18. The consumer decodes, and the producer encodes, a message in the charset named in MSH-18 of the message, and in this charset when the message has no MSH-18, or MSH-18 names a charset that is not supported. The CamelCharsetName header and exchange property are not used. The default is the defaultCharset of the component (ISO-8859-1).

String

hl7Headers (common)

Whether the consumer sets the CamelMllp headers from the fields of the MSH segment of the received message, such as CamelMllpMessageType from MSH-9.

true

boolean

requireEndOfData (common)

Whether an MLLP frame must end with END_OF_BLOCK (0x1c) followed by END_OF_DATA (a carriage return, 0x0d), as the MLLP standard specifies. Some systems do not send the final END_OF_DATA byte: disable this option to accept a frame that ends with END_OF_BLOCK. Applies to the messages the consumer receives and the acknowledgements the producer receives.

true

boolean

stringPayload (common)

Whether the consumer sets the body to a String, decoded in the charset named in MSH-18 of the message, or in charsetName when the message has no MSH-18 or MSH-18 names a charset that is not supported. When disabled, the body is the byte array as received, and the CamelCharsetName exchange property holds that charset.

true

boolean

validatePayload (common)

Whether to validate the HL7 payloads received (an MSH segment first, a segment delimiter at the end, no MLLP framing bytes inside). The consumer fails the exchange of an invalid message with an MllpInvalidMessageException. The producer fails the exchange with an MllpInvalidAcknowledgementException when the acknowledgement is invalid or has no MSA segment.

false

boolean

acceptTimeout (consumer)

The SO_TIMEOUT, in milliseconds, of the server socket of the consumer: how long one accept() call waits for a new connection before the consumer checks that it is still running and waits again. It is also how long an idle thread of the consumer is kept.

60000

int

backlog (consumer)

The backlog of the server socket of the consumer: the maximum length of the queue of incoming connections that are not accepted yet. A connection that arrives when the queue is full is refused. A value of 0 or less uses the default of the JVM (50).

5

Integer

bindRetryInterval (consumer)

The time, in milliseconds, the consumer waits between two attempts to bind its server socket to the port (see bindTimeout).

5000

int

bindTimeout (consumer)

How long, in milliseconds, the consumer keeps trying to bind its server socket to the port when it starts. Without lenientBind, the consumer fails to start when the port is not bound within this time.

30000

int

bridgeErrorHandler (consumer)

Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to receive incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. If disabled, the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions by logging them at WARN or ERROR level and ignored.

true

boolean

lenientBind (consumer)

Whether the consumer starts without waiting for its server socket to be bound. When enabled, the consumer binds the port in a background thread, retrying until bindTimeout, and the route starts even when the port is not available yet. When disabled, the consumer fails to start when it cannot bind the port within bindTimeout.

false

boolean

maxConcurrentConsumers (consumer)

The maximum number of client connections the consumer serves at the same time, each in its own thread. A new connection that arrives when this number of connections is active is reset.

5

int

reuseAddress (consumer)

Whether to enable the SO_REUSEADDR socket option, on the server socket of the consumer and on the socket of the producer.

false

Boolean

exceptionHandler (consumer (advanced))

To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored.

ExceptionHandler

exchangePattern (consumer (advanced))

The exchange pattern of the endpoint. The consumer always creates InOut exchanges: with autoAck disabled, InOnly sends no acknowledgement when the route sets none, while InOut reports a missing acknowledgement as an error. With InOnly, the producer sends the message without waiting for an acknowledgement.

Enum values:

  • InOnly

  • InOut

InOut

ExchangePattern

connectTimeout (producer)

The timeout, in milliseconds, for the producer to establish the TCP connection. 0 means no timeout.

30000

int

idleTimeoutStrategy (producer)

What the producer does with a connection that has been idle for idleTimeout: RESET sets SO_LINGER to 0 and closes the socket, which resets the connection; CLOSE closes the socket gracefully. The consumer always resets an idle connection.

Enum values:

  • RESET

  • CLOSE

RESET

MllpIdleTimeoutStrategy

keepAlive (producer)

Whether to enable the SO_KEEPALIVE socket option on the TCP connections of the producer and of the consumer.

true

Boolean

tcpNoDelay (producer)

Whether to enable the TCP_NODELAY socket option (which disables Nagle’s algorithm) on the TCP connections of the producer and of the consumer.

true

Boolean

lazyStartProducer (producer (advanced))

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

maxBufferSize (advanced)

Maximum size, in bytes, of the buffer used when receiving or sending data over the wire.

1073741824

int

minBufferSize (advanced)

Minimum size, in bytes, of the buffer used when receiving or sending data over the wire.

2048

int

readTimeout (advanced)

The SO_TIMEOUT, in milliseconds, used once the start of an MLLP frame has been received: how long each further read waits for the rest of the frame. When it expires, the producer fails the exchange with an MllpAcknowledgementTimeoutException, and the consumer resets the connection.

5000

int

receiveBufferSize (advanced)

The SO_RCVBUF socket option, in bytes: the size of the receive buffer of the operating system for the sockets of the producer and of the consumer. The operating system takes it as a hint. A value of 0 or less keeps the default of the operating system.

8192

Integer

receiveTimeout (advanced)

The SO_TIMEOUT, in milliseconds, of the first read of a message: how long the producer waits for the acknowledgement to start arriving, and how long the consumer waits for data on a connection before it checks the idleTimeout and waits again.

15000

int

sendBufferSize (advanced)

The SO_SNDBUF socket option, in bytes: the size of the send buffer of the operating system for the TCP connections of the producer and of the consumer. The operating system takes it as a hint. A value of 0 or less keeps the default of the operating system.

8192

Integer

hostnameVerification (security)

Whether the producer checks that the certificate of the server matches the host it connects to, when SSL/TLS is used. When disabled, any certificate accepted by the trust store is accepted, whatever host it was issued for.

true

boolean

sslContextParameters (security)

Sets the SSLContextParameters for securing TCP connections. If set, the MLLP component will use SSL/TLS for securing both producer and consumer TCP connections. This allows the configuration of trust stores, key stores, protocols, and other SSL/TLS settings. If not set, the MLLP component will use plain TCP communication.

SSLContextParameters

idleTimeout (tcp)

The time, in milliseconds, after which a connection with no activity is ended. The producer closes or resets its connection, as set by idleTimeoutStrategy, and opens a new one for the next message. The consumer resets a client connection that has received no message for this time, checked each time the receiveTimeout expires. Not set, or 0 or less, disables the idle timeout.

Integer

Message Headers

The MLLP component supports the following message header(s), which is/are listed below:

Name Description Default Type

CamelMllpLocalAddress (common)

Constant: MLLP_LOCAL_ADDRESS

The local address of the TCP connection, as the text of its socket address (such as /127.0.0.1:2575).

String

CamelMllpRemoteAddress (common)

Constant: MLLP_REMOTE_ADDRESS

The remote address of the TCP connection, as the text of its socket address (such as /127.0.0.1:52344).

String

CamelMllpSslClientCertSubjectName (consumer)

Constant: MLLP_SSL_CLIENT_CERT_SUBJECT_NAME

The subject name of the certificate of the client, when the client sends one over SSL/TLS.

String

CamelMllpSslClientCertIssuerName (consumer)

Constant: MLLP_SSL_CLIENT_CERT_ISSUER_NAME

The issuer name of the certificate of the client, when the client sends one over SSL/TLS.

String

CamelMllpSslClientCertSerialNo (consumer)

Constant: MLLP_SSL_CLIENT_CERT_SERIAL_NO

The serial number of the certificate of the client, when the client sends one over SSL/TLS.

String

CamelMllpSslClientCertNotBefore (consumer)

Constant: MLLP_SSL_CLIENT_CERT_NOT_BEFORE

The start of the validity period (not before) of the certificate of the client, when the client sends one over SSL/TLS.

Date

CamelMllpSslClientCertNotAfter (consumer)

Constant: MLLP_SSL_CLIENT_CERT_NOT_AFTER

The end of the validity period (not after) of the certificate of the client, when the client sends one over SSL/TLS.

Date

CamelMllpAcknowledgement (common)

Constant: MLLP_ACKNOWLEDGEMENT

The HL7 acknowledgement as a byte array, without the MLLP framing: for the producer, the acknowledgement received (with the InOut pattern); for the consumer, the acknowledgement sent back.

byte[]

CamelMllpAcknowledgementString (common)

Constant: MLLP_ACKNOWLEDGEMENT_STRING

The HL7 acknowledgement as a String: for the producer, the acknowledgement received, decoded in the charset named in its MSH-18, or charsetName; for the consumer, the acknowledgement sent back.

String

CamelMllpAcknowledgementType (common)

Constant: MLLP_ACKNOWLEDGEMENT_TYPE

The type of the HL7 acknowledgement, from MSA-1, such as AA, AE, AR or CA: for the producer, of the acknowledgement received; for the consumer, of the acknowledgement it generated with autoAck.

String

CamelMllpSendingApplication (consumer)

Constant: MLLP_SENDING_APPLICATION

The value of MSH-3 (Sending Application) of the received message.

String

CamelMllpSendingFacility (consumer)

Constant: MLLP_SENDING_FACILITY

The value of MSH-4 (Sending Facility) of the received message.

String

CamelMllpReceivingApplication (consumer)

Constant: MLLP_RECEIVING_APPLICATION

The value of MSH-5 (Receiving Application) of the received message.

String

CamelMllpReceivingFacility (consumer)

Constant: MLLP_RECEIVING_FACILITY

The value of MSH-6 (Receiving Facility) of the received message.

String

CamelMllpTimestamp (consumer)

Constant: MLLP_TIMESTAMP

The value of MSH-7 (Date/Time of Message) of the received message.

String

CamelMllpSecurity (consumer)

Constant: MLLP_SECURITY

The value of MSH-8 (Security) of the received message.

String

CamelMllpMessageType (consumer)

Constant: MLLP_MESSAGE_TYPE

The value of MSH-9 (Message Type) of the received message, such as ADTA01.

String

CamelMllpEventType (consumer)

Constant: MLLP_EVENT_TYPE

The first component of MSH-9 (the message code, such as ADT) of the received message.

String

CamelMllpTriggerEvent (consumer)

Constant: MLLP_TRIGGER_EVENT

The second component of MSH-9 (the trigger event, such as A01) of the received message.

String

CamelMllpMessageControlId (consumer)

Constant: MLLP_MESSAGE_CONTROL

The value of MSH-10 (Message Control ID) of the received message.

String

CamelMllpProcessingId (consumer)

Constant: MLLP_PROCESSING_ID

The value of MSH-11 (Processing ID) of the received message.

String

CamelMllpVersionId (consumer)

Constant: MLLP_VERSION_ID

The value of MSH-12 (Version ID) of the received message.

String

CamelMllpCharset (consumer)

Constant: MLLP_CHARSET

The value of MSH-18 (Character Set) of the received message.

String

Message Body

The message body at each side of the MLLP component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.

Side Body Description

Consumer

text (java.lang.String)

The HL7 message without the MLLP envelope, as a String in the charset of MSH-18 or charsetName, or a byte array with stringPayload=false.

  • With stringPayload=false: bytes (byte[])

Consumer reply

any

The body is not sent back: the acknowledgement is the CamelMllpAcknowledgement or CamelMllpAcknowledgementString exchange property, or with autoAck an HL7 ACK (AA, or AE when the exchange failed).

Producer input

text, bytes, stream or file

The HL7 message as a String (encoded in the charset of MSH-18, or charsetName) or a byte array. Another body, such as a stream or a file, is converted to a byte array; no body, or a body that cannot be converted, fails.

Producer output

unchanged

The body is left as it was: with InOut the acknowledgement is in the CamelMllpAcknowledgement (byte array) and CamelMllpAcknowledgementString headers.

The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.

Usage

MLLP Consumer

The MLLP Consumer supports receiving MLLP-framed messages and sending HL7 Acknowledgements. The MLLP Consumer can automatically generate the HL7 Acknowledgement (HL7 Application Acknowledgements only - AA, AE and AR), or the acknowledgement can be specified using the CamelMllpAcknowledgement exchange property. Additionally, the type of acknowledgement that will be generated can be controlled by setting the CamelMllpAcknowledgementType exchange property. The MLLP Consumer can read messages without sending any HL7 Acknowledgement if the automatic acknowledgement is disabled and the exchange pattern is InOnly.

Exchange Properties

The type of acknowledgment the MLLP Consumer generates, and the state of the TCP Socket can be controlled by these properties on the Camel exchange:

Key

Type

Description

CamelMllpAcknowledgement

byte[]

If present, this property will be sent to the client as the MLLP Acknowledgement

CamelMllpAcknowledgementString

String

If present and CamelMllpAcknowledgement is not present, this property will we sent to the client as the MLLP Acknowledgement

CamelMllpAcknowledgementMsaText

String

If neither CamelMllpAcknowledgement or CamelMllpAcknowledgementString are present and autoAck is true, this property can be used to specify the contents of MSA-3 in the generated HL7 acknowledgement

CamelMllpAcknowledgementType

String

If neither CamelMllpAcknowledgement or CamelMllpAcknowledgementString are present and autoAck is true, this property can be used to specify the HL7 acknowledgement type (i.e. AA, AE, AR)

CamelMllpAutoAcknowledge

Boolean

Overrides the autoAck query parameter

CamelMllpCloseConnectionBeforeSend

Boolean

If true, the Socket will be closed before sending data

CamelMllpResetConnectionBeforeSend

Boolean

If true, the Socket will be reset before sending data

CamelMllpCloseConnectionAfterSend

Boolean

If true, the Socket will be closed immediately after sending data

CamelMllpResetConnectionAfterSend

Boolean

If true, the Socket will be reset immediately after sending any data

MLLP Producer

The MLLP Producer supports sending MLLP-framed messages and receiving HL7 Acknowledgements. The MLLP Producer interrogates the HL7 Acknowledgements and raises exceptions if a negative acknowledgement is received. The received acknowledgement is interrogated and an exception is raised in the event of a negative acknowledgement. The MLLP Producer can ignore acknowledgements when configured with InOnly exchange pattern.

Exchange Properties

The state of the TCP Socket can be controlled by these properties on the Camel exchange:

Key

Type

Description

CamelMllpCloseConnectionBeforeSend

Boolean

If true, the Socket will be closed before sending data

CamelMllpResetConnectionBeforeSend

Boolean

If true, the Socket will be reset before sending data

CamelMllpCloseConnectionAfterSend

Boolean

If true, the Socket will be closed immediately after sending data

CamelMllpResetConnectionAfterSend

Boolean

If true, the Socket will be reset immediately after sending any data

Character set

The character set of an HL7 message is named in MSH-18 (for example UNICODE UTF-8 or 8859/1), and the charsetName option is the character set of a message that has no MSH-18, or whose MSH-18 names a character set that Java does not support. It is ISO-8859-1 by default, from the defaultCharset option of the component.

  • The consumer decodes the message into a String body in the character set of MSH-18, else charsetName. The CamelMllpCharset header holds the MSH-18 value of the message.

  • The producer encodes a String body in the character set of MSH-18, else charsetName, so a message keeps the character set it declares when a route relays it from an MLLP consumer to an MLLP producer. A byte[] body is sent as it is.

The CamelCharsetName header and exchange property do not choose the character set of the MLLP producer, as they may come from another endpoint of the route. The MLLP consumer sets the CamelCharsetName exchange property only with stringPayload=false, to the character set of the byte[] body, for converting it to text later in the route.

Example

The first route is an MLLP server that acknowledges each HL7 message automatically. The second route sends it an ADT message, and logs the acknowledgement it gets back in the CamelMllpAcknowledgementString header. The segments of an HL7 message are separated by a carriage return (\r):

- route:
    from:
      uri: mllp://0.0.0.0:8888
      steps:
        - log:
            message: "Received ${body}"
- route:
    from:
      uri: timer:send
      parameters:
        repeatCount: 1
      steps:
        - setBody:
            expression:
              constant:
                expression: "MSH|^~\\&|SENDER|HOSPITAL|RECEIVER|HOSPITAL|20260101120000||ADT^A01|MSG00001|P|2.5\rPID|1||12345||Doe^John"
        - to:
            uri: mllp://localhost:8888
        - log:
            message: "Acknowledgement: ${header.CamelMllpAcknowledgementString}"

Using TLS

Set sslContextParameters on the endpoint, or useGlobalSslContextParameters on the component, to secure the connections of the consumer and the producer with TLS. The trust store, key store, protocols and cipher suites are configured with the Camel JSSE Configuration Utility.

The producer checks that the certificate of the server matches the hostname of the endpoint, with the same rules as an HTTPS client. A producer that connects by IP address needs a certificate that lists that address as a subject alternative name, and a producer URI without a host name (such as mllp://8888) cannot pass the check. Set hostnameVerification=false to turn this check off; the certificate chain is still validated against the trust store.