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

   Fixes [CAMEL-26183](https://issues.apache.org/jira/browse/CAMEL-26183).
   
   ## What was wrong
   
   `MllpTcpClientProducer.process` handled only a `String` or a `byte[]` body. 
For any other body (an `InputStream`, a `StringBuilder`, a file, a HAPI 
`Message`, a `Map`) the payload stayed `null`, an empty MLLP envelope was 
written, and with `InOut` the producer waited until the receive timeout and 
failed with a `MllpAcknowledgementTimeoutException`. With `InOnly` the exchange 
completed and the peer got an empty message.
   
   ## What changed
   
   - A `CharSequence` (such as a `StringBuilder`) is encoded like a `String`: 
in the charset of the exchange, else `charsetName`.
   - Any other body is converted to a `byte[]` with the mandatory type 
converter (stream, file, `ByteBuffer`, a HAPI `Message` with camel-hl7 on the 
classpath, ...). When the exchange has no charset set, the `charsetName` 
charset is set on it first, so a converter that encodes text uses the same 
charset as a `String` body.
   - A body that cannot be converted (such as a `Map`) fails fast with a 
`MllpInvalidMessageException`, with the `NoTypeConversionAvailableException` as 
cause. Nothing is written to the socket.
   
   ## Tests
   
   New `MllpTcpClientProducerBodyConversionTest` (loopback against an mllp 
consumer, no external service):
   - an `InputStream` body is received byte for byte and acknowledged (AA),
   - a `StringBuilder` with non-ASCII text is sent in the `charsetName` charset 
(UTF-8),
   - a `Map` body fails at once with `MllpInvalidMessageException`.
   
   All 3 fail without the fix (each with 
`MllpAcknowledgementTimeoutException`). Full module: 363 tests, 0 failures, 3 
skipped (`mvn clean install -Psourcecheck`).
   
   ## Docs and generated files
   
   - `@BodyTypes` producerIn described the old behaviour ("another body ... is 
sent as an empty message"); it now lists text, bytes, stream and file and says 
what fails. Regenerated `mllp.json` and copied it and the doc into 
`camel-catalog`.
   - Component doc: the producer paragraph describes the conversion.
   - Upgrade guide 4.24: a `camel-mllp` entry, because an `InOnly` route with 
an unconvertible body used to complete and now fails.
   
   ## Not changed
   
   - An empty `String` or `byte[]` body is still sent as an empty message, as 
before.
   - The consumer side is unchanged.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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