Repository: camel Updated Branches: refs/heads/master e5a094d32 -> dda3a043d
Added support for HL7 Commit Acknowledgements Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/93c4fe34 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/93c4fe34 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/93c4fe34 Branch: refs/heads/master Commit: 93c4fe34b9824d7194448e62c46b4bb8482e71b7 Parents: 9912647 Author: Quinn Stevenson <qu...@pronoia-solutions.com> Authored: Tue Jan 5 13:49:12 2016 -0700 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Jan 6 17:47:59 2016 +0100 ---------------------------------------------------------------------- components/camel-mllp/LIMITATIONS.md | 4 ---- components/camel-mllp/README.md | 13 ++++++------ .../component/mllp/MllpTcpClientProducer.java | 22 ++++++++++++++++---- 3 files changed, 25 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/93c4fe34/components/camel-mllp/LIMITATIONS.md ---------------------------------------------------------------------- diff --git a/components/camel-mllp/LIMITATIONS.md b/components/camel-mllp/LIMITATIONS.md index dab7957..b7d906e 100644 --- a/components/camel-mllp/LIMITATIONS.md +++ b/components/camel-mllp/LIMITATIONS.md @@ -12,10 +12,6 @@ maxConnections are not enforced yet - an unlimited number of connections are all Suspending a MLLP Consumer is not yet implemented -RouteBuilders for standard usage - - The plan for this is to have a few RouteBuilders packaged with the component that - can be used as-is for some of the standard use-cases ( i.e. MLLP to JMS, JMS to MLLP, etc). - JMX Instrumentation is not yet implemented - Manually reset connection - Suspend a consumer http://git-wip-us.apache.org/repos/asf/camel/blob/93c4fe34/components/camel-mllp/README.md ---------------------------------------------------------------------- diff --git a/components/camel-mllp/README.md b/components/camel-mllp/README.md index e7b0fc9..c7042af 100644 --- a/components/camel-mllp/README.md +++ b/components/camel-mllp/README.md @@ -8,9 +8,10 @@ http://www.hl7.org/documentcenter/public_temp_E7494E36-1C23-BA17-0C5E72EF77542E1 The camel-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 component is capable of handling both byte[] and String payloads which allows using other HL7 Libraries (i.e. HAPI) -to parse the messages. When String payloads are specified, the component will use the systems default Charset for -encoding/decoding, but this can be overridden. +The component uses byte[] payloads, and relies on the Camel type conversion system for converting other payload +types to/from byte[]. This allows using other HL7 Libraries (i.e. HAPI) to parse the messages. The component +provides a 'charset' URI option that will cause the endpoint to set the CamelCharsetName property on the exchange +which allows the proper conversion of byte[] to String payloads for Consumers. The component provides a simple URI for configuring MLLP endpoints: MLLP-Producers: @@ -21,9 +22,9 @@ MLLP-Consumers: MLLP-Producers also interrogate the HL7 Acknowledgment received from the external system and if a negative acknowledgment is received, the producer sets an exception on the exchange indicating the type of negative acknowledgement that was -received (i.e. a HL7 Application Reject Acknowledgement or a HL7 Application Error Acknowledgement). This enables -the use of Camel Redelivery Policies to configure redelivery attempts and routing erroneous messages to alternate -endpoints for analysis. +received (i.e. a HL7 Application Reject Acknowledgement, Application Error Acknowledgement, +Commit Reject Acknowledgement and Commit Error Acknowledgement). This enables the use of Camel Redelivery +Policies to configure redelivery attempts and routing erroneous messages to alternate endpoints for analysis. MLLP-Consumers will, by default, automatically generate an acknowledgement. A HL7 Application Accept Acknowledgment will be generated for successfully processed messages, or a HL7 Application Error Acknowledgement for messages where an http://git-wip-us.apache.org/repos/asf/camel/blob/93c4fe34/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpClientProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpClientProducer.java b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpClientProducer.java index 4a313ef..8a8e3a4 100644 --- a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpClientProducer.java +++ b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpClientProducer.java @@ -131,6 +131,7 @@ public class MllpTcpClientProducer extends DefaultProducer { if (SEGMENT_DELIMITER == acknowledgementBytes[i]) { final byte bM = 77; final byte bS = 83; + final byte bC = 67; final byte bA = 65; final byte bE = 69; final byte bR = 82; @@ -142,25 +143,38 @@ public class MllpTcpClientProducer extends DefaultProducer { if (bM == acknowledgementBytes[i + 1] && bS == acknowledgementBytes[i + 2] && bA == acknowledgementBytes[i + 3] && fieldDelim == acknowledgementBytes[i + 4]) { // Found the beginning of the MSA - the next two bytes should be our acknowledgement code msaStartIndex = i + 1; - if (bA != acknowledgementBytes[i + 5]) { + if (bA != acknowledgementBytes[i + 5] && bC != acknowledgementBytes[i + 5]) { exchange.setException(new MllpInvalidAcknowledgementException(new String(acknowledgementBytes))); } else { + String acknowledgemenTypeString; switch (acknowledgementBytes[i + 6]) { case bA: // We have an AA - make sure that's the end of the field if (fieldDelim != acknowledgementBytes[i + 7]) { exchange.setException(new MllpInvalidAcknowledgementException(new String(acknowledgementBytes))); } - message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE, "AA"); + if (bA == acknowledgementBytes[i + 5]) { + message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE, "AA"); + } else { + message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE, "CA"); + } break; case bE: // We have an AE exchange.setException(new MllpApplicationErrorAcknowledgementException(new String(acknowledgementBytes))); - message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE, "AE"); + if (bA == acknowledgementBytes[i + 5]) { + message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE, "AE"); + } else { + message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE, "CE"); + } break; case bR: exchange.setException(new MllpApplicationRejectAcknowledgementException(new String(acknowledgementBytes))); - message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE, "AR"); + if (bA == acknowledgementBytes[i + 5]) { + message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE, "AR"); + } else { + message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE, "CR"); + } break; default: exchange.setException(new MllpInvalidAcknowledgementException(new String(acknowledgementBytes)));