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 component use byte[]
payloads, and relies on Camel type
conversion to convert byte[]
to other types.
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
The component level is the highest level which holds general and common configurations that are inherited by the endpoints. 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.
Configuring components can be done with the Component DSL, in a configuration file (application.properties|yaml), or directly with Java code.
Configuring Endpoint Options
Where you find yourself configuring the most is on endpoints, as endpoints often have many options, which allows you to configure what you need the endpoint to do. The options are also categorized into whether the endpoint is used as consumer (from) or as a producer (to), or used for 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, which allows to not hardcode urls, port numbers, sensitive information, and other settings. In other words placeholders allows to externalize the configuration from your code, and gives more flexibility and reuse.
The following two sections lists all the options, firstly for the component followed by the endpoint.
Component Options
The MLLP component supports 32 options, which are listed below.
Name | Description | Default | Type |
---|---|---|---|
Enable/Disable the automatic generation of a MLLP Acknowledgement MLLP Consumers only. |
true |
boolean |
|
Sets the default charset to use. |
String |
||
Sets the default configuration to use when creating MLLP endpoints. |
MllpConfiguration |
||
Enable/Disable the automatic generation of message headers from the HL7 Message MLLP Consumers only. |
true |
boolean |
|
Enable/Disable strict compliance to the MLLP standard. The MLLP standard specifies START_OF_BLOCKhl7 payloadEND_OF_BLOCKEND_OF_DATA, however, some systems do not send the final END_OF_DATA byte. This setting controls whether or not the final END_OF_DATA byte is required or optional. |
true |
boolean |
|
Enable/Disable converting the payload to a String. If enabled, HL7 Payloads received from external systems will be validated converted to a String. If the charsetName property is set, that character set will be used for the conversion. If the charsetName property is not set, the value of MSH-18 will be used to determine th appropriate character set. If MSH-18 is not set, then the default ISO-8859-1 character set will be use. |
true |
boolean |
|
Enable/Disable the validation of HL7 Payloads If enabled, HL7 Payloads received from external systems will be validated (see Hl7Util.generateInvalidPayloadExceptionMessage for details on the validation). If and invalid payload is detected, a MllpInvalidMessageException (for consumers) or a MllpInvalidAcknowledgementException will be thrown. |
false |
boolean |
|
Timeout (in milliseconds) while waiting for a TCP connection TCP Server Only. |
60000 |
int |
|
The maximum queue length for incoming connection indications (a request to connect) is set to the backlog parameter. If a connection indication arrives when the queue is full, the connection is refused. |
5 |
Integer |
|
TCP Server Only - The number of milliseconds to wait between bind attempts. |
5000 |
int |
|
TCP Server Only - The number of milliseconds to retry binding to a server port. |
30000 |
int |
|
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 |
|
TCP Server Only - Allow the endpoint to start before the TCP ServerSocket is bound. In some environments, it may be desirable to allow the endpoint to start before the TCP ServerSocket is bound. |
false |
boolean |
|
The maximum number of concurrent MLLP Consumer connections that will be allowed. If a new connection is received and the maximum is number are already established, the new connection will be reset immediately. |
5 |
int |
|
Enable/disable the SO_REUSEADDR socket option. |
false |
Boolean |
|
Sets the exchange pattern when the consumer creates an exchange. Enum values:
|
InOut |
ExchangePattern |
|
Timeout (in milliseconds) for establishing for a TCP connection TCP Client only. |
30000 |
int |
|
decide what action to take when idle timeout occurs. Possible values are : RESET: set SO_LINGER to 0 and reset the socket CLOSE: close the socket gracefully default is RESET. Enum values:
|
RESET |
MllpIdleTimeoutStrategy |
|
Enable/disable the SO_KEEPALIVE socket option. |
true |
Boolean |
|
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 |
|
Enable/disable the TCP_NODELAY socket option. |
true |
Boolean |
|
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 |
|
Set the default character set to use for byte to/from String conversions. |
ISO-8859-1 |
String |
|
Whether to log PHI. |
true |
Boolean |
|
Set the maximum number of bytes of PHI that will be logged in a log entry. |
5120 |
Integer |
|
Maximum buffer size used when receiving or sending data over the wire. |
1073741824 |
int |
|
Minimum buffer size used when receiving or sending data over the wire. |
2048 |
int |
|
The SO_TIMEOUT value (in milliseconds) used after the start of an MLLP frame has been received. |
5000 |
int |
|
Sets the SO_RCVBUF option to the specified value (in bytes). |
8192 |
Integer |
|
The SO_TIMEOUT value (in milliseconds) used when waiting for the start of an MLLP frame. |
15000 |
int |
|
Sets the SO_SNDBUF option to the specified value (in bytes). |
8192 |
Integer |
|
The approximate idle time allowed before the Client TCP Connection will be reset. A null value or a value less than or equal to zero will disable the idle timeout. |
Integer |
Endpoint Options
The MLLP endpoint is configured using URI syntax:
mllp:hostname:port
with the following path and query parameters:
Query Parameters (28 parameters)
Name | Description | Default | Type |
---|---|---|---|
Enable/Disable the automatic generation of a MLLP Acknowledgement MLLP Consumers only. |
true |
boolean |
|
Sets the default charset to use. |
String |
||
Enable/Disable the automatic generation of message headers from the HL7 Message MLLP Consumers only. |
true |
boolean |
|
Enable/Disable strict compliance to the MLLP standard. The MLLP standard specifies START_OF_BLOCKhl7 payloadEND_OF_BLOCKEND_OF_DATA, however, some systems do not send the final END_OF_DATA byte. This setting controls whether or not the final END_OF_DATA byte is required or optional. |
true |
boolean |
|
Enable/Disable converting the payload to a String. If enabled, HL7 Payloads received from external systems will be validated converted to a String. If the charsetName property is set, that character set will be used for the conversion. If the charsetName property is not set, the value of MSH-18 will be used to determine th appropriate character set. If MSH-18 is not set, then the default ISO-8859-1 character set will be use. |
true |
boolean |
|
Enable/Disable the validation of HL7 Payloads If enabled, HL7 Payloads received from external systems will be validated (see Hl7Util.generateInvalidPayloadExceptionMessage for details on the validation). If and invalid payload is detected, a MllpInvalidMessageException (for consumers) or a MllpInvalidAcknowledgementException will be thrown. |
false |
boolean |
|
Timeout (in milliseconds) while waiting for a TCP connection TCP Server Only. |
60000 |
int |
|
The maximum queue length for incoming connection indications (a request to connect) is set to the backlog parameter. If a connection indication arrives when the queue is full, the connection is refused. |
5 |
Integer |
|
TCP Server Only - The number of milliseconds to wait between bind attempts. |
5000 |
int |
|
TCP Server Only - The number of milliseconds to retry binding to a server port. |
30000 |
int |
|
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 |
|
TCP Server Only - Allow the endpoint to start before the TCP ServerSocket is bound. In some environments, it may be desirable to allow the endpoint to start before the TCP ServerSocket is bound. |
false |
boolean |
|
The maximum number of concurrent MLLP Consumer connections that will be allowed. If a new connection is received and the maximum is number are already established, the new connection will be reset immediately. |
5 |
int |
|
Enable/disable the SO_REUSEADDR socket option. |
false |
Boolean |
|
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 |
||
Sets the exchange pattern when the consumer creates an exchange. Enum values:
|
InOut |
ExchangePattern |
|
Timeout (in milliseconds) for establishing for a TCP connection TCP Client only. |
30000 |
int |
|
decide what action to take when idle timeout occurs. Possible values are : RESET: set SO_LINGER to 0 and reset the socket CLOSE: close the socket gracefully default is RESET. Enum values:
|
RESET |
MllpIdleTimeoutStrategy |
|
Enable/disable the SO_KEEPALIVE socket option. |
true |
Boolean |
|
Enable/disable the TCP_NODELAY socket option. |
true |
Boolean |
|
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 |
|
Maximum buffer size used when receiving or sending data over the wire. |
1073741824 |
int |
|
Minimum buffer size used when receiving or sending data over the wire. |
2048 |
int |
|
The SO_TIMEOUT value (in milliseconds) used after the start of an MLLP frame has been received. |
5000 |
int |
|
Sets the SO_RCVBUF option to the specified value (in bytes). |
8192 |
Integer |
|
The SO_TIMEOUT value (in milliseconds) used when waiting for the start of an MLLP frame. |
15000 |
int |
|
Sets the SO_SNDBUF option to the specified value (in bytes). |
8192 |
Integer |
|
The approximate idle time allowed before the Client TCP Connection will be reset. A null value or a value less than or equal to zero will disable the idle timeout. |
Integer |
Message Headers
The MLLP component supports 18 message header(s), which is/are listed below:
Name | Description | Default | Type |
---|---|---|---|
CamelMllpLocalAddress (common) Constant: |
The local TCP Address of the Socket. |
String |
|
CamelMllpRemoteAddress (common) Constant: |
The remote TCP Address of the Socket. |
String |
|
CamelMllpAcknowledgement (common) Constant: |
The HL7 Acknowledgment received in bytes. |
byte[] |
|
CamelMllpAcknowledgementString (common) Constant: |
The HL7 Acknowledgment received, converted to a String. |
String |
|
CamelMllpAcknowledgementType (common) Constant: |
The HL7 acknowledgement type (AA, AE, AR, etc). |
String |
|
CamelMllpSendingApplication (consumer) Constant: |
MSH-3 value. |
String |
|
CamelMllpSendingFacility (consumer) Constant: |
MSH-4 value. |
String |
|
CamelMllpReceivingApplication (consumer) Constant: |
MSH-5 value. |
String |
|
CamelMllpReceivingFacility (consumer) Constant: |
MSH-6 value. |
String |
|
Constant: |
MSH-7 value. |
String |
|
Constant: |
MSH-8 value. |
String |
|
CamelMllpMessageType (consumer) Constant: |
MSH-9 value. |
String |
|
Constant: |
MSH-9.1 value. |
String |
|
CamelMllpTriggerEvent (consumer) Constant: |
MSH-9.2 value. |
String |
|
CamelMllpMessageControlId (consumer) Constant: |
MSH-10 value. |
String |
|
CamelMllpProcessingId (consumer) Constant: |
MSH-11 value. |
String |
|
Constant: |
MSH-12 value. |
String |
|
Constant: |
MSH-18 value. |
String |
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 exchange pattern is InOnly.
Exchange Properties
The type of acknowledgment the MLLP Consumer generates and 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 we sent to client as the MLLP Acknowledgement |
CamelMllpAcknowledgementString |
String |
If present and CamelMllpAcknowledgement is not present, this property will we sent to 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 Acknowledgments 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 |
Spring Boot Auto-Configuration
When using mllp with Spring Boot make sure to use the following Maven dependency to have support for auto configuration:
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-mllp-starter</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
The component supports 33 options, which are listed below.
Name | Description | Default | Type |
---|---|---|---|
Timeout (in milliseconds) while waiting for a TCP connection TCP Server Only. |
60000 |
Integer |
|
Enable/Disable the automatic generation of a MLLP Acknowledgement MLLP Consumers only. |
true |
Boolean |
|
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 |
|
The maximum queue length for incoming connection indications (a request to connect) is set to the backlog parameter. If a connection indication arrives when the queue is full, the connection is refused. |
5 |
Integer |
|
TCP Server Only - The number of milliseconds to wait between bind attempts. |
5000 |
Integer |
|
TCP Server Only - The number of milliseconds to retry binding to a server port. |
30000 |
Integer |
|
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 |
|
Sets the default charset to use. |
String |
||
Sets the default configuration to use when creating MLLP endpoints. The option is a org.apache.camel.component.mllp.MllpConfiguration type. |
MllpConfiguration |
||
Timeout (in milliseconds) for establishing for a TCP connection TCP Client only. |
30000 |
Integer |
|
Set the default character set to use for byte to/from String conversions. |
ISO-8859-1 |
String |
|
Whether to enable auto configuration of the mllp component. This is enabled by default. |
Boolean |
||
Sets the exchange pattern when the consumer creates an exchange. |
ExchangePattern |
||
Enable/Disable the automatic generation of message headers from the HL7 Message MLLP Consumers only. |
true |
Boolean |
|
The approximate idle time allowed before the Client TCP Connection will be reset. A null value or a value less than or equal to zero will disable the idle timeout. |
Integer |
||
decide what action to take when idle timeout occurs. Possible values are : RESET: set SO_LINGER to 0 and reset the socket CLOSE: close the socket gracefully default is RESET. |
MllpIdleTimeoutStrategy |
||
Enable/disable the SO_KEEPALIVE socket option. |
true |
Boolean |
|
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 |
|
TCP Server Only - Allow the endpoint to start before the TCP ServerSocket is bound. In some environments, it may be desirable to allow the endpoint to start before the TCP ServerSocket is bound. |
false |
Boolean |
|
Whether to log PHI. |
true |
Boolean |
|
Set the maximum number of bytes of PHI that will be logged in a log entry. |
5120 |
Integer |
|
Maximum buffer size used when receiving or sending data over the wire. |
1073741824 |
Integer |
|
The maximum number of concurrent MLLP Consumer connections that will be allowed. If a new connection is received and the maximum is number are already established, the new connection will be reset immediately. |
5 |
Integer |
|
Minimum buffer size used when receiving or sending data over the wire. |
2048 |
Integer |
|
The SO_TIMEOUT value (in milliseconds) used after the start of an MLLP frame has been received. |
5000 |
Integer |
|
Sets the SO_RCVBUF option to the specified value (in bytes). |
8192 |
Integer |
|
The SO_TIMEOUT value (in milliseconds) used when waiting for the start of an MLLP frame. |
15000 |
Integer |
|
Enable/Disable strict compliance to the MLLP standard. The MLLP standard specifies START_OF_BLOCKhl7 payloadEND_OF_BLOCKEND_OF_DATA, however, some systems do not send the final END_OF_DATA byte. This setting controls whether or not the final END_OF_DATA byte is required or optional. |
true |
Boolean |
|
Enable/disable the SO_REUSEADDR socket option. |
false |
Boolean |
|
Sets the SO_SNDBUF option to the specified value (in bytes). |
8192 |
Integer |
|
Enable/Disable converting the payload to a String. If enabled, HL7 Payloads received from external systems will be validated converted to a String. If the charsetName property is set, that character set will be used for the conversion. If the charsetName property is not set, the value of MSH-18 will be used to determine th appropriate character set. If MSH-18 is not set, then the default ISO-8859-1 character set will be use. |
true |
Boolean |
|
Enable/disable the TCP_NODELAY socket option. |
true |
Boolean |
|
Enable/Disable the validation of HL7 Payloads If enabled, HL7 Payloads received from external systems will be validated (see Hl7Util.generateInvalidPayloadExceptionMessage for details on the validation). If and invalid payload is detected, a MllpInvalidMessageException (for consumers) or a MllpInvalidAcknowledgementException will be thrown. |
false |
Boolean |