oscerd commented on PR #28950:
URL: https://github.com/apache/camel/pull/28950#issuecomment-6588535605
Thanks Claus, you are right. I checked it first: with a `List.of("a", "b")`
body, `ArrayTypeConverter` fails on `Array.set` with "argument type mismatch",
so `sendMessage` and `publishMessage` failed with a `TypeConversionException`,
and an empty list was sent as an empty message. `MNSUtils.setMessageBody` now
has the same guard as the eventbridge fix: a collection, or an array other than
`byte[]`, is not converted to bytes and is sent as its `toString()`, as before
this PR. The new tests `listIsSentAsItsText`, `listIsPublishedAsItsText` and
`emptyListIsSentAsItsText` in `MNSProducerBodyTest` cover it, and all three
fail without the guard. The doc, the body types and the upgrade guide now name
a `List` next to the `Map` and the POJO.
Good idea on the consumer side. The `consumerOut` body type and the "Message
body" section of the doc now say that binary data that is valid UTF-8 arrives
as a String, so `getBody(byte[].class)` (or `convertBodyTo(byte[].class)`) is
the reliable way to get the bytes of a message: it gives back the same bytes in
both cases, as UTF-8 is the default charset of Camel.
Agreed on the open questions: the deprecation of
`MNSOperations.RECEIVE_MESSAGE` and `MNSEndpoint.resolveConsumerOperation()`
goes to a follow-up, and a Map or a POJO keeps being sent as its `toString()`.
_Claude Code on behalf of Andrea Cosentino (oscerd)_
--
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]