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

   Part of #3117, batch 4 (Messaging): default data types on the two messaging 
sources whose body is always bytes.
   
   **Draft:** a source's `out` default runs where it should only with 
CAMEL-27258, which applies it when the message is handed to `kamelet:sink`, 
before the consuming route. CAMEL-27258 is merged in Camel main, but the 
snapshot CI uses predates it. Without it, the transformer runs after the 
consuming route has ended (see #3275). Ready for review once CI has a snapshot 
with CAMEL-27258.
   
   | Kamelet | `out` | What changes (before → after) |
   |---|---|---|
   | `pulsar-source` | `binary` | Body: `byte[]` → `byte[]` (unchanged). 
`Content-Type`: not set → `application/octet-stream` |
   | `mqtt5-source` | `binary` | Body: `byte[]` → `byte[]` (unchanged). 
`Content-Type`: not set → `application/octet-stream`. The publisher's MQTT 5 
content type stays in `CamelPahoMqtt5MsgProperties` |
   
   Both `Output:` paragraphs now say that the `Content-Type` header is 
`application/octet-stream`.
   
   ### Why `binary` is safe here
   - **`pulsar-source`:** the Camel Pulsar consumer is always a 
`Consumer<byte[]>` (`newConsumer()` with the bytes schema), and the body is 
`message.getValue()`. The Kamelet has no option for a schema, so no option can 
give another body.
   - **`mqtt5-source`:** the body is always `MqttMessage.getPayload()`, a 
`byte[]`.
   - Neither component sets a `Content-Type` header today, so `binary` replaces 
nothing.
   
   The other Messaging rows of the proposal on #3117 get no default: the JMS, 
RabbitMQ, SMPP, NATS and Kafka sources and sinks (see #3275), and the sinks 
that send `Content-Type` on to the other system (decision D2).
   
   ### Tests
   Run locally with Camel 4.24.0-SNAPSHOT from main with CAMEL-27258.
   - **Citrus:** `MessagingIT#pulsar`: 2 of 2 pass.
     - The `pulsar-source` test now expects `X-Content-Type: 
ct=application/octet-stream` (was `ct=`). The body type stays `[B`.
     - Its route now sets `Content-Type: text/plain` after turning the bytes 
into text for the HTTP server, because Citrus reads an 
`application/octet-stream` body as bytes.
     - Before the change, the same test with `ct=` passed: `[B`, no 
`Content-Type`.
   - **`mqtt5-source`, by hand,** because the `mqtt5` Citrus tests are disabled 
(#2925, #3288). `camel run` against `eclipse-mosquitto:2`, with two messages 
published by `mosquitto_pub -V 5`: `Hello MQTT`, and `{"a":1}` with the MQTT 5 
content type `application/json`. A `log` step right after the source printed:
     - Before (main): `bodyType=[B ct=` for both messages.
     - After: `bodyType=[B ct=application/octet-stream` for both messages. The 
second one still had `application/json` in 
`CamelPahoMqtt5MsgProperties.getContentType()`.
     - The `Content-Type` was already set in the first step of the consuming 
route, as CAMEL-27258 intends.
   - **Build:** `./mvnw clean install` from the root passes, run twice.
   
   ### Overlap
   - #3285 and #3294 change `pulsar-sink` and its tests 
(`pulsar-sink-key-based-route*`, `pulsar-sink-route*`). This PR changes 
`pulsar-source` and only the `pulsar-source-route*` test files, so there is no 
conflict.
   
   ### Upgrade note
   For #3190, under the data types, when this is merged:
   - `pulsar-source` and `mqtt5-source` now set the `Content-Type` header to 
`application/octet-stream`. The body is `byte[]` as before. For `mqtt5-source`, 
the publisher's MQTT 5 content type is still in the 
`CamelPahoMqtt5MsgProperties` header. A route that relied on `Content-Type` not 
being set, for example one that sends the message on over HTTP, now sends 
`application/octet-stream`.
   
   _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