This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git


The following commit(s) were added to refs/heads/main by this push:
     new 80b5e43e3 chore: default data types on the Pulsar and MQTT 5 sources 
(#3117) (#3300)
80b5e43e3 is described below

commit 80b5e43e33bc17f695349a8a2c9ad5c9deb5076e
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Nov 20 21:13:31 2026 +0100

    chore: default data types on the Pulsar and MQTT 5 sources (#3117) (#3300)
    
    pulsar-source and mqtt5-source declare an `out` default of `binary`
    (application-octet-stream). Both always give the payload as byte[], so the
    body is unchanged; the Content-Type header is now application/octet-stream.
    Needs CAMEL-27258, which runs a source's out type when the message is handed
    to kamelet:sink.
    
    The pulsar-source Citrus test now expects that Content-Type, and its route
    sends the text on as text/plain, as Citrus reads application/octet-stream as
    bytes.
    
    
    Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
    
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 kamelets/mqtt5-source.kamelet.yaml                                | 8 +++++++-
 kamelets/pulsar-source.kamelet.yaml                               | 8 +++++++-
 .../src/main/resources/META-INF/kamelets-index.json               | 4 ++--
 .../src/main/resources/kamelets/mqtt5-source.kamelet.yaml         | 8 +++++++-
 .../src/main/resources/kamelets/pulsar-source.kamelet.yaml        | 8 +++++++-
 .../src/test/resources/pulsar/pulsar-source-route.citrus.it.yaml  | 6 +++---
 .../src/test/resources/pulsar/pulsar-source-route.yaml            | 5 ++++-
 7 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/kamelets/mqtt5-source.kamelet.yaml 
b/kamelets/mqtt5-source.kamelet.yaml
index 3d619115a..06cf5c333 100644
--- a/kamelets/mqtt5-source.kamelet.yaml
+++ b/kamelets/mqtt5-source.kamelet.yaml
@@ -35,7 +35,7 @@ spec:
 
       Use it to collect readings and events from IoT devices and other MQTT 
clients, when the broker or the clients use MQTT 5. A topic with wildcards, 
such as `sensors/#`, receives from many topics at once. The broker must support 
MQTT 5.
 
-      Output: the body is the payload, as bytes. The `CamelMqttTopic` header 
is the topic the message was published to, `CamelMqttQoS` its quality of 
service, and `CamelPahoMqtt5MsgProperties` holds the MQTT 5 properties of the 
message, such as its user properties.
+      Output: the body is the payload, as bytes, and the `Content-Type` header 
is `application/octet-stream`, whatever content type the publisher gave in the 
MQTT 5 properties. The `CamelMqttTopic` header is the topic the message was 
published to, `CamelMqttQoS` its quality of service, and 
`CamelPahoMqtt5MsgProperties` holds the MQTT 5 properties of the message, such 
as its user properties.
 
       Good to know: it receives only the messages published while it is 
connected, plus, when it subscribes, the last retained message of each matching 
topic. It subscribes with quality of service 2 (exactly once) unless `qos` is 
set. Each running copy needs its own `clientId`: two clients with the same ID 
keep pushing each other off the broker and lose messages. When it is not set, a 
unique one is generated. It connects with no TLS unless `brokerUrl` starts with 
`ssl://`. With TLS it ch [...]
     required:
@@ -91,6 +91,12 @@ spec:
         - urn:camel:group:credentials
   dataTypes:
     out:
+      default: binary
+      types:
+        binary:
+          format: "application-octet-stream"
+          description: "The payload of the message, as bytes."
+          mediaType: application/octet-stream
       headers:
         CamelMqttTopic:
           title: "Topic"
diff --git a/kamelets/pulsar-source.kamelet.yaml 
b/kamelets/pulsar-source.kamelet.yaml
index e6ce9db88..6ca1cb92b 100644
--- a/kamelets/pulsar-source.kamelet.yaml
+++ b/kamelets/pulsar-source.kamelet.yaml
@@ -31,6 +31,12 @@ metadata:
 spec:
   dataTypes:
     out:
+      default: binary
+      types:
+        binary:
+          format: "application-octet-stream"
+          description: "The payload of the message, as bytes."
+          mediaType: application/octet-stream
       headers:
         topic_name:
           title: "Topic Name"
@@ -62,7 +68,7 @@ spec:
 
       Use it to process events or data that other applications publish to 
Pulsar. Several copies can share the work with a `SHARED` or `KEY_SHARED` 
subscription.
 
-      Output: the body is the payload, as bytes. The headers give the topic 
(`topic_name`), the key (`key`), the Pulsar properties as a Map (`properties`), 
the `message_id`, the `publish_time` and the `producer_name`.
+      Output: the body is the payload, as bytes, and the `Content-Type` header 
is `application/octet-stream`. The other headers give the topic (`topic_name`), 
the key (`key`), the Pulsar properties as a Map (`properties`), the 
`message_id`, the `publish_time` and the `producer_name`.
 
       Good to know: the subscription (`subscriptionName`, `subs` by default) 
remembers what was read, so messages sent while the source is stopped are read 
when it starts again. A new subscription starts at the newest message, unless 
`subscriptionInitialPosition` is `EARLIEST`. A message whose processing fails 
is delivered again after one minute, again and again, unless 
`maxRedeliverCount` is set with a `SHARED` or `KEY_SHARED` subscription. A 
message whose processing takes longer than ` [...]
     required:
diff --git 
a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json 
b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
index 825647db4..72db3aaf2 100644
--- a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
+++ b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
@@ -1515,7 +1515,7 @@
     "supportLevel" : "Stable",
     "title" : "MQTT 5 Source",
     "summary" : "Receives each message published to a topic on an MQTT broker, 
such as Eclipse Mosquitto or HiveMQ, with MQTT 5.",
-    "description" : "Receives each message published to a topic on an MQTT 
broker, such as Eclipse Mosquitto or HiveMQ, with MQTT 5.\n\nUse it to collect 
readings and events from IoT devices and other MQTT clients, when the broker or 
the clients use MQTT 5. A topic with wildcards, such as `sensors/#`, receives 
from many topics at once. The broker must support MQTT 5.\n\nOutput: the body 
is the payload, as bytes. The `CamelMqttTopic` header is the topic the message 
was published to, `Came [...]
+    "description" : "Receives each message published to a topic on an MQTT 
broker, such as Eclipse Mosquitto or HiveMQ, with MQTT 5.\n\nUse it to collect 
readings and events from IoT devices and other MQTT clients, when the broker or 
the clients use MQTT 5. A topic with wildcards, such as `sensors/#`, receives 
from many topics at once. The broker must support MQTT 5.\n\nOutput: the body 
is the payload, as bytes, and the `Content-Type` header is 
`application/octet-stream`, whatever conten [...]
     "group" : "MQTT 5",
     "namespace" : "Messaging",
     "provider" : "Apache Software Foundation"
@@ -1735,7 +1735,7 @@
     "supportLevel" : "Stable",
     "title" : "Pulsar Source",
     "summary" : "Receives each message from a topic in Apache Pulsar, or from 
every topic whose name matches a pattern, through a named subscription.",
-    "description" : "Receives each message from a topic in Apache Pulsar, or 
from every topic whose name matches a pattern, through a named 
subscription.\n\nUse it to process events or data that other applications 
publish to Pulsar. Several copies can share the work with a `SHARED` or 
`KEY_SHARED` subscription.\n\nOutput: the body is the payload, as bytes. The 
headers give the topic (`topic_name`), the key (`key`), the Pulsar properties 
as a Map (`properties`), the `message_id`, the `pub [...]
+    "description" : "Receives each message from a topic in Apache Pulsar, or 
from every topic whose name matches a pattern, through a named 
subscription.\n\nUse it to process events or data that other applications 
publish to Pulsar. Several copies can share the work with a `SHARED` or 
`KEY_SHARED` subscription.\n\nOutput: the body is the payload, as bytes, and 
the `Content-Type` header is `application/octet-stream`. The other headers give 
the topic (`topic_name`), the key (`key`), the Pu [...]
     "group" : "Pulsar",
     "namespace" : "Messaging",
     "provider" : "Apache Software Foundation"
diff --git 
a/library/camel-kamelets/src/main/resources/kamelets/mqtt5-source.kamelet.yaml 
b/library/camel-kamelets/src/main/resources/kamelets/mqtt5-source.kamelet.yaml
index 3d619115a..06cf5c333 100644
--- 
a/library/camel-kamelets/src/main/resources/kamelets/mqtt5-source.kamelet.yaml
+++ 
b/library/camel-kamelets/src/main/resources/kamelets/mqtt5-source.kamelet.yaml
@@ -35,7 +35,7 @@ spec:
 
       Use it to collect readings and events from IoT devices and other MQTT 
clients, when the broker or the clients use MQTT 5. A topic with wildcards, 
such as `sensors/#`, receives from many topics at once. The broker must support 
MQTT 5.
 
-      Output: the body is the payload, as bytes. The `CamelMqttTopic` header 
is the topic the message was published to, `CamelMqttQoS` its quality of 
service, and `CamelPahoMqtt5MsgProperties` holds the MQTT 5 properties of the 
message, such as its user properties.
+      Output: the body is the payload, as bytes, and the `Content-Type` header 
is `application/octet-stream`, whatever content type the publisher gave in the 
MQTT 5 properties. The `CamelMqttTopic` header is the topic the message was 
published to, `CamelMqttQoS` its quality of service, and 
`CamelPahoMqtt5MsgProperties` holds the MQTT 5 properties of the message, such 
as its user properties.
 
       Good to know: it receives only the messages published while it is 
connected, plus, when it subscribes, the last retained message of each matching 
topic. It subscribes with quality of service 2 (exactly once) unless `qos` is 
set. Each running copy needs its own `clientId`: two clients with the same ID 
keep pushing each other off the broker and lose messages. When it is not set, a 
unique one is generated. It connects with no TLS unless `brokerUrl` starts with 
`ssl://`. With TLS it ch [...]
     required:
@@ -91,6 +91,12 @@ spec:
         - urn:camel:group:credentials
   dataTypes:
     out:
+      default: binary
+      types:
+        binary:
+          format: "application-octet-stream"
+          description: "The payload of the message, as bytes."
+          mediaType: application/octet-stream
       headers:
         CamelMqttTopic:
           title: "Topic"
diff --git 
a/library/camel-kamelets/src/main/resources/kamelets/pulsar-source.kamelet.yaml 
b/library/camel-kamelets/src/main/resources/kamelets/pulsar-source.kamelet.yaml
index e6ce9db88..6ca1cb92b 100644
--- 
a/library/camel-kamelets/src/main/resources/kamelets/pulsar-source.kamelet.yaml
+++ 
b/library/camel-kamelets/src/main/resources/kamelets/pulsar-source.kamelet.yaml
@@ -31,6 +31,12 @@ metadata:
 spec:
   dataTypes:
     out:
+      default: binary
+      types:
+        binary:
+          format: "application-octet-stream"
+          description: "The payload of the message, as bytes."
+          mediaType: application/octet-stream
       headers:
         topic_name:
           title: "Topic Name"
@@ -62,7 +68,7 @@ spec:
 
       Use it to process events or data that other applications publish to 
Pulsar. Several copies can share the work with a `SHARED` or `KEY_SHARED` 
subscription.
 
-      Output: the body is the payload, as bytes. The headers give the topic 
(`topic_name`), the key (`key`), the Pulsar properties as a Map (`properties`), 
the `message_id`, the `publish_time` and the `producer_name`.
+      Output: the body is the payload, as bytes, and the `Content-Type` header 
is `application/octet-stream`. The other headers give the topic (`topic_name`), 
the key (`key`), the Pulsar properties as a Map (`properties`), the 
`message_id`, the `publish_time` and the `producer_name`.
 
       Good to know: the subscription (`subscriptionName`, `subs` by default) 
remembers what was read, so messages sent while the source is stopped are read 
when it starts again. A new subscription starts at the newest message, unless 
`subscriptionInitialPosition` is `EARLIEST`. A message whose processing fails 
is delivered again after one minute, again and again, unless 
`maxRedeliverCount` is set with a `SHARED` or `KEY_SHARED` subscription. A 
message whose processing takes longer than ` [...]
     required:
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/pulsar/pulsar-source-route.citrus.it.yaml
 
b/tests/camel-kamelets-itest/src/test/resources/pulsar/pulsar-source-route.citrus.it.yaml
index ede516ff0..fd095322a 100644
--- 
a/tests/camel-kamelets-itest/src/test/resources/pulsar/pulsar-source-route.citrus.it.yaml
+++ 
b/tests/camel-kamelets-itest/src/test/resources/pulsar/pulsar-source-route.citrus.it.yaml
@@ -16,7 +16,7 @@
 # ---------------------------------------------------------------------------
 
 name: pulsar-source-route-test
-description: 'pulsar-source receives a message from a topic in Pulsar, as 
bytes, with the topic, key, properties and message ID as headers'
+description: 'pulsar-source receives a message from a topic in Pulsar, as 
bytes with the Content-Type application/octet-stream, and with the topic, key, 
properties and message ID as headers'
 actions:
   # Start Pulsar
   - testcontainers:
@@ -46,7 +46,7 @@ actions:
                 - name: "pulsar.service.url"
                   value: 
"pulsar://${CITRUS_TESTCONTAINERS_PULSAR_HOST}:${CITRUS_TESTCONTAINERS_PULSAR_PORT}"
 
-  # The source gives the payload as bytes, with the topic, key, properties, 
message ID, publish time and producer name
+  # The source gives the payload as bytes with the Content-Type 
application/octet-stream, and with the topic, key, properties, message ID, 
publish time and producer name
   - http:
       server: "httpServer"
       receiveRequest:
@@ -57,7 +57,7 @@ actions:
             - name: "X-Body-Type"
               value: '[B'
             - name: "X-Content-Type"
-              value: 'ct='
+              value: 'ct=application/octet-stream'
             - name: "topic_name"
               value: 'persistent://public/default/orders'
             - name: "key"
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/pulsar/pulsar-source-route.yaml 
b/tests/camel-kamelets-itest/src/test/resources/pulsar/pulsar-source-route.yaml
index 96db8de7b..3b46954b5 100644
--- 
a/tests/camel-kamelets-itest/src/test/resources/pulsar/pulsar-source-route.yaml
+++ 
b/tests/camel-kamelets-itest/src/test/resources/pulsar/pulsar-source-route.yaml
@@ -37,9 +37,12 @@
         - setHeader:
             name: X-Origin
             simple: "${header.properties[origin]}"
-        # the body is bytes: give the HTTP server text
+        # the body is bytes: give the HTTP server text (Citrus reads an 
application/octet-stream body as bytes)
         - convertBodyTo:
             type: "java.lang.String"
+        - setHeader:
+            name: Content-Type
+            constant: "text/plain"
         - to:
             uri: "{{http.sink.url}}/result"
 

Reply via email to