davsclaus opened a new pull request, #3337:
URL: https://github.com/apache/camel-kamelets/pull/3337

   Two new Kamelets for HL7 v2 over MLLP, the hospital interface protocol, on 
the Camel `mllp` component (Stable).
   
   ## `mllp-source`
   
   It listens on a TCP port and gives each HL7 v2 message to the flow. It sends 
the HL7 acknowledgement (ACK) by itself.
   
   - Options: `port` (required), `host` (default `0.0.0.0`), `charset` (used 
when MSH-18 is empty; ISO-8859-1 when not set).
   - Output: the body is the HL7 message as text, with its segments separated 
by `\r`. The text is read in the charset that MSH-18 names (for example 
`UNICODE UTF-8`), or in `charset`. The MSH fields are in headers: 
`CamelMllpMessageType`, `CamelMllpEventType`, `CamelMllpTriggerEvent`, 
`CamelMllpMessageControlId`, the sending and receiving application and 
facility, `CamelMllpTimestamp`, `CamelMllpProcessingId` and 
`CamelMllpVersionId`. `CamelMllpRemoteAddress` is the sender. These headers are 
declared under `dataTypes.out`.
   - ACK: `AA` once the flow has finished, or `AE` when a step fails, with the 
name of the error class in MSA-3. A message without a complete MSH still 
reaches the flow but gets no ACK.
   - Network exposure: it listens on all interfaces by default, the same as 
`webhook-source`, with no login and no TLS. The description says so and tells 
the reader to protect the port. Under the security model, the network exposure 
of a source is operator responsibility.
   - The template removes the `CamelCharsetName` exchange property. The 
component always sets it, to ISO-8859-1 by default. Left in place, it made 
later steps turn the text into bytes in ISO-8859-1, so `Łucja` became `?ucja`. 
The test catches this: 124 bytes instead of 126 when the step is taken out.
   
   ## `mllp-sink`
   
   It sends the body as an HL7 v2 message and reads the ACK.
   
   - Options: `host`, `port` (both required), `charset` (default `ISO-8859-1`), 
`connectTimeout` (default 30000), `ackTimeout` (passed to `receiveTimeout`, 
default 15000).
   - Input: text, sent in `charset`, or bytes, which are sent as they are. The 
component does not read MSH-18 when it sends, so the description tells the 
reader to set `charset` to match it.
   - Output: the body is unchanged. The ACK is in 
`CamelMllpAcknowledgementType` (`AA`), `CamelMllpAcknowledgementString` and 
`CamelMllpAcknowledgement` (bytes).
   - A negative ACK (`AE` → `MllpApplicationErrorAcknowledgementException`, 
`AR` → `MllpApplicationRejectAcknowledgementException`) fails the message. The 
ACK headers are still set, so an error handler can read MSA-3. A receiver that 
cannot be reached fails with `ConnectException`, and one that does not answer 
in time fails with `MllpAcknowledgementTimeoutException`. Both were checked by 
hand.
   - Headers: the producer reads no `CamelMllp*` headers. The 
connection-control keys are exchange properties, not headers, so a message 
cannot steer where it is sent. The template still removes:
     - `CamelMllpAcknowledgement*`, so the ACK headers afterwards always belong 
to this send;
     - the `CamelCharsetName` header. The component reads it before its own 
`charsetName`, so a wire header `CamelCharsetName: UTF-16` re-encoded the 
message, the receiver could not build an ACK, and the sink timed out.
   
     The template also sets the exchange property `CamelCharsetName` to 
`charset`. Without it, a relay of `mllp-source` into `mllp-sink` with `charset: 
UTF-8` was still sent in ISO-8859-1, because the property that the source or an 
earlier send left behind won.
   
   ## TLS
   
   `sslContextParameters` is an object option and would need a bean in the 
template. This PR does not add Kamelet options for it. The descriptions name 
the global SSL settings instead (`camel.ssl.*` with 
`camel.component.mllp.useGlobalSslContextParameters=true`), as `http-source` 
does. I checked by hand with a self-signed PKCS12: a source app with only a key 
store and a sink app with only a trust store connected over TLS and got `AA`. 
Per-Kamelet trust store and key store options, like those of `ftps-*`, can 
follow when someone needs them.
   
   ## Tests
   
   `MllpIT` adds the package `mllp` and runs fully locally, with no container. 
Its port comes from `ServerPorts.next()`. `mllp-sink-route` sends five messages 
to `mllp-source-route`, which runs in another integration:
   1. ADT^A01 as text. The source logs the body type and text and every MSH 
header, and it is bound to `0.0.0.0`. The sink logs an unchanged String body 
and an `AA` ACK with swapped sender and receiver, `MSG00001A` and 
`MSA|AA|MSG00001`.
   2. UTF-8 text with MSH-18 `UNICODE UTF-8` and a `CamelCharsetName: UTF-16` 
header. The source reads it correctly and later turns it into 126 UTF-8 bytes. 
The sink gets `AA`.
   3. A body of bytes. The sink gets `AA`.
   4. The source flow throws. The sink fails with 
`MllpApplicationErrorAcknowledgementException` and AE, and MSA-3 is 
`java.lang.IllegalArgumentException`.
   5. The source flow rejects the message. The sink fails with 
`MllpApplicationRejectAcknowledgementException` and AR.
   
   Local results:
   - `./mvnw -o clean install -DskipITs`: passes.
   - `./mvnw -o verify -pl tests/camel-kamelets-itest -Dit.test=MllpIT`: 1 
test, 0 failures, 33 s.
   
   Both Kamelets carry `camel.apache.org/kamelet.verified: "true"`.
   
   Fixes #3333.
   
   ## Upgrade note
   
   New Kamelets `mllp-source` and `mllp-sink` receive and send HL7 v2 messages 
over MLLP. The source acknowledges each message automatically (AA, or AE when 
the flow fails), and the sink fails the message on a negative acknowledgement 
(AE or AR).
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to