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 0550293f4 Fix #3331: new kafka-share-source Kamelet, reads Kafka 
topics through a share group (KIP-932) (#3343)
0550293f4 is described below

commit 0550293f4f23515d6f688eec70dcc9942482a89d
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Nov 22 09:25:14 2026 +0100

    Fix #3331: new kafka-share-source Kamelet, reads Kafka topics through a 
share group (KIP-932) (#3343)
    
    * Fix #3331: new kafka-share-source Kamelet, reads Kafka topics through a 
share group (KIP-932)
    
    The Kamelet uses the kafka-share component (Preview): the records of the
    topics are shared like a queue between the consumers of a share group, more
    of them than the partitions, and each record is acknowledged on its own.
    Options, security and output follow kafka-source, with shareGroup,
    consumersCount and onFailure added, and the offset options left out.
    The new kafka-delivery-count header says how many times a record was
    delivered.
    
    Citrus tests against apache/kafka 4.4.0: body and headers, two consumers of
    one group, a failed record and a record released by the route are delivered
    again (and a record header CamelKafkaShareAcknowledge is ignored), and a
    Protobuf record read through Apicurio Registry.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
    
    * chore: regenerate the catalog files after merging main
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
    
    ---------
    
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 .../camel-kamelets-catalog-sbom.json               |  24 +-
 docs/modules/ROOT/nav.adoc                         |   1 +
 kamelets/kafka-share-source.kamelet.yaml           | 405 +++++++++++++++++++++
 .../main/resources/META-INF/kamelets-index.json    |  10 +
 .../kamelets/kafka-share-source.kamelet.yaml       | 405 +++++++++++++++++++++
 ...afka-share-schema-registry-route.citrus.it.yaml |  96 +++++
 .../kafka/kafka-share-schema-registry-route.yaml   |  58 +++
 .../kafka/kafka-share-source-route.citrus.it.yaml  | 236 ++++++++++++
 .../resources/kafka/kafka-share-source-route.yaml  |  51 +++
 .../resources/kafka/share-group-earliest.groovy    |  43 +++
 10 files changed, 1328 insertions(+), 1 deletion(-)

diff --git a/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json 
b/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
index eb8858cba..f71db6c17 100644
--- a/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
+++ b/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
@@ -686,6 +686,11 @@
     "type" : "library",
     "name" : "kafka-manual-commit-action",
     "version" : "4.24.0-SNAPSHOT"
+  }, {
+    "bom-ref" : "kamelet:kafka-share-source",
+    "type" : "library",
+    "name" : "kafka-share-source",
+    "version" : "4.24.0-SNAPSHOT"
   }, {
     "bom-ref" : "kamelet:kafka-sink",
     "type" : "library",
@@ -1926,6 +1931,17 @@
       "name" : "camel.apache.org/versioned-by",
       "value" : "runtime"
     } ]
+  }, {
+    "bom-ref" : "pkg:maven/org.apache.camel/[email protected]",
+    "type" : "library",
+    "group" : "org.apache.camel",
+    "name" : "camel-kafka-share",
+    "version" : "4.24.0-SNAPSHOT",
+    "purl" : "pkg:maven/org.apache.camel/[email protected]",
+    "properties" : [ {
+      "name" : "camel.apache.org/versioned-by",
+      "value" : "runtime"
+    } ]
   }, {
     "bom-ref" : "pkg:maven/org.apache.camel/[email protected]",
     "type" : "library",
@@ -2419,7 +2435,7 @@
   } ],
   "dependencies" : [ {
     "ref" : "camel-kamelets-catalog",
-    "dependsOn" : [ "kamelet:avro-deserialize-action", 
"kamelet:avro-serialize-action", "kamelet:aws-bedrock-agent-runtime-sink", 
"kamelet:aws-bedrock-agent-sink", "kamelet:aws-bedrock-text-sink", 
"kamelet:aws-cloudtrail-source", "kamelet:aws-cloudwatch-sink", 
"kamelet:aws-comprehend-sink", "kamelet:aws-ddb-sink", 
"kamelet:aws-ddb-streams-source", "kamelet:aws-ec2-sink", 
"kamelet:aws-eventbridge-sink", "kamelet:aws-eventbridge-source", 
"kamelet:aws-kinesis-firehose-sink", "kamelet:aws-ki [...]
+    "dependsOn" : [ "kamelet:avro-deserialize-action", 
"kamelet:avro-serialize-action", "kamelet:aws-bedrock-agent-runtime-sink", 
"kamelet:aws-bedrock-agent-sink", "kamelet:aws-bedrock-text-sink", 
"kamelet:aws-cloudtrail-source", "kamelet:aws-cloudwatch-sink", 
"kamelet:aws-comprehend-sink", "kamelet:aws-ddb-sink", 
"kamelet:aws-ddb-streams-source", "kamelet:aws-ec2-sink", 
"kamelet:aws-eventbridge-sink", "kamelet:aws-eventbridge-source", 
"kamelet:aws-kinesis-firehose-sink", "kamelet:aws-ki [...]
   }, {
     "ref" : "kamelet:avro-deserialize-action",
     "dependsOn" : [ 
"pkg:maven/org.apache.camel/[email protected]", 
"pkg:maven/org.apache.camel/[email protected]" ]
@@ -2825,6 +2841,9 @@
   }, {
     "ref" : "kamelet:kafka-manual-commit-action",
     "dependsOn" : [ "pkg:maven/org.apache.camel/[email protected]", 
"pkg:maven/org.apache.camel/[email protected]" ]
+  }, {
+    "ref" : "kamelet:kafka-share-source",
+    "dependsOn" : [ 
"pkg:maven/org.apache.camel/[email protected]", 
"pkg:maven/org.apache.camel/[email protected]", 
"pkg:maven/org.apache.camel/[email protected]", 
"pkg:maven/org.apache.camel/[email protected]" ]
   }, {
     "ref" : "kamelet:kafka-sink",
     "dependsOn" : [ 
"pkg:maven/org.apache.camel/[email protected]", 
"pkg:maven/org.apache.camel/[email protected]", 
"pkg:maven/org.apache.camel/[email protected]" ]
@@ -3323,6 +3342,9 @@
   }, {
     "ref" : "pkg:maven/org.apache.camel/[email protected]",
     "dependsOn" : [ ]
+  }, {
+    "ref" : "pkg:maven/org.apache.camel/[email protected]",
+    "dependsOn" : [ ]
   }, {
     "ref" : "pkg:maven/org.apache.camel/[email protected]",
     "dependsOn" : [ ]
diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index 59a61509b..e833e8877 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -134,6 +134,7 @@
 * xref:kafka-batch-manual-commit-action.adoc[]
 * xref:kafka-batch-source.adoc[]
 * xref:kafka-manual-commit-action.adoc[]
+* xref:kafka-share-source.adoc[]
 * xref:kafka-sink.adoc[]
 * xref:kafka-source.adoc[]
 * xref:langchain4j-ingest-file-source.adoc[]
diff --git a/kamelets/kafka-share-source.kamelet.yaml 
b/kamelets/kafka-share-source.kamelet.yaml
new file mode 100644
index 000000000..033704d96
--- /dev/null
+++ b/kamelets/kafka-share-source.kamelet.yaml
@@ -0,0 +1,405 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+apiVersion: camel.apache.org/v1
+kind: Kamelet
+metadata:
+  name: kafka-share-source
+  annotations:
+    camel.apache.org/kamelet.support.level: "Preview"
+    camel.apache.org/catalog.version: "4.24.0-SNAPSHOT"
+    camel.apache.org/kamelet.icon: 
"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxOS4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiDQoJIHZpZXdCb3g9IjAgMCA1MDAgNTAwIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1MD
 [...]
+    camel.apache.org/provider: "Apache Software Foundation"
+    camel.apache.org/kamelet.group: "Kafka"
+    camel.apache.org/kamelet.namespace: "Kafka"
+  labels:
+    camel.apache.org/kamelet.type: "source"
+    camel.apache.org/kamelet.verified: "true"
+spec:
+  definition:
+    title: "Kafka Share Source"
+    description: |-
+      Receives each record from one or more Apache Kafka topics through a 
share group, which hands out the records like a queue: each record goes to one 
of many consumers.
+
+      Use it to share the work of a topic between many integrations or 
threads, more of them than the topic has partitions, such as orders or tasks 
that each take a while to handle, when the order of the records does not 
matter. To read the records in order, or to read them again from a given 
position, use `kafka-source`. Share groups are on by default from Kafka 4.2.
+
+      Output: the body is the value of the record, as text. With 
`schemaRegistryVendor`, the value is read with its schema from the registry and 
the body is JSON text, such as `{"id": 7, "item": "camel"}` for an Avro record. 
A Protobuf record is turned into JSON by the Protobuf JSON mapping, such as 
`{"id":7,"item":"camel"}`: the names of the fields are in lowerCamelCase 
(`orderNo` for `order_no`), 64-bit numbers are text, and the fields that have 
their default value, such as 0 or empty  [...]
+
+      Good to know: each record is acknowledged on its own once the 
integration has handled it, and a record that was handled is not delivered 
again. A record whose handling fails is released by default: Kafka delivers it 
again, to this or another consumer, up to `group.share.delivery.count.limit` 
times in all (5 by default, a broker setting), and then drops it. Set 
`onFailure` to `REJECT` to drop it at once, or to `ACCEPT` to count it as 
handled. To decide for one record, set the header [...]
+    required:
+      - topic
+      - bootstrapServers
+      - saslAuthType
+      - shareGroup
+    type: object
+    properties:
+      topic:
+        title: Topic Names
+        description: "The topics to read from, separated by commas. A share 
group cannot read the topics whose names match a regular expression."
+        type: string
+        example: "orders"
+      bootstrapServers:
+        title: Bootstrap Servers
+        description: "The address of one or more Kafka brokers to connect to 
first, as `host:port`, separated by commas. The other brokers of the cluster 
are found from them."
+        type: string
+        example: "broker1:9092,broker2:9092"
+      shareGroup:
+        title: Share Group
+        description: "The name of the share group. All the consumers with the 
same share group, in this and in other integrations, share the records of the 
topics: each record goes to one of them. The group remembers which records were 
handled, so that a restarted integration goes on where it stopped."
+        type: string
+        example: "order-workers"
+      saslAuthType:
+        title: Authentication Type
+        description: "How to log in to Kafka. It has no default and must be 
set. `NONE` connects with no login and no TLS, as a local Kafka expects; 
`PLAIN`, `SCRAM_SHA_256` and `SCRAM_SHA_512` log in with `saslUsername` and 
`saslPassword`; `SSL` connects over TLS and logs in with the client certificate 
in `sslKeystoreLocation`, when set; `OAUTH` logs in with the `oauth` options; 
`AWS_MSK_IAM` (Amazon MSK) and `KERBEROS` take their credentials from the 
environment the integration runs in [...]
+        type: string
+        enum: ["NONE", "PLAIN", "SCRAM_SHA_256", "SCRAM_SHA_512", "SSL", 
"OAUTH", "AWS_MSK_IAM", "KERBEROS"]
+      saslUsername:
+        title: Username
+        description: "The user name to log in to Kafka with. Required when 
`saslAuthType` is `PLAIN`, `SCRAM_SHA_256` or `SCRAM_SHA_512`."
+        type: string
+        x-descriptors:
+          - urn:camel:group:credentials
+      saslPassword:
+        title: Password
+        description: "The password of `saslUsername`. Required when 
`saslAuthType` is `PLAIN`, `SCRAM_SHA_256` or `SCRAM_SHA_512`."
+        type: string
+        format: password
+        x-descriptors:
+          - urn:camel:group:credentials
+      oauthClientId:
+        title: OAuth Client ID
+        description: "The ID of the client registered with the OAuth 2.0 
provider. Required when `saslAuthType` is `OAUTH`."
+        type: string
+      oauthClientSecret:
+        title: OAuth Client Secret
+        description: "The secret of the OAuth client `oauthClientId`, from the 
OAuth 2.0 provider. Required when `saslAuthType` is `OAUTH`."
+        type: string
+        format: password
+        x-descriptors:
+          - urn:camel:group:credentials
+      oauthTokenEndpointUri:
+        title: OAuth Token URL
+        description: "The URL of the OAuth 2.0 provider where the Kamelet gets 
its access token. Required when `saslAuthType` is `OAUTH`. The URL must also be 
listed in the JVM system property 
`org.apache.kafka.sasl.oauthbearer.allowed.urls`, or the integration fails to 
start."
+        type: string
+        example: "https://auth.example.com/oauth2/token";
+      oauthScope:
+        title: OAuth Scope
+        description: "The scope to ask the OAuth 2.0 provider for, when it 
requires one. Only used when `saslAuthType` is `OAUTH`."
+        type: string
+        example: "kafka"
+      sslTruststoreLocation:
+        title: SSL Truststore Location
+        description: "The path of a trust store file, in JKS format, with the 
certificates to trust the brokers by. Needed only when the brokers use a 
certificate that Java does not trust by default, such as a self-signed one."
+        type: string
+        example: "/etc/kafka/truststore.jks"
+      sslTruststorePassword:
+        title: SSL Truststore Password
+        description: "The password of the trust store file in 
`sslTruststoreLocation`."
+        type: string
+        format: password
+        x-descriptors:
+          - urn:camel:group:credentials
+      sslKeystoreLocation:
+        title: SSL Keystore Location
+        description: "The path of a key store file, in JKS format, with the 
certificate and private key of the client. Needed only to log in with a client 
certificate (mutual TLS), usually with `saslAuthType` `SSL`."
+        type: string
+        example: "/etc/kafka/keystore.jks"
+      sslKeystorePassword:
+        title: SSL Keystore Password
+        description: "The password of the key store file in 
`sslKeystoreLocation`."
+        type: string
+        format: password
+        x-descriptors:
+          - urn:camel:group:credentials
+      sslKeyPassword:
+        title: SSL Key Password
+        description: "The password of the private key in the key store file in 
`sslKeystoreLocation`."
+        type: string
+        format: password
+        x-descriptors:
+          - urn:camel:group:credentials
+      consumersCount:
+        title: Consumers Count
+        description: "How many consumers of the share group this Kamelet runs, 
each on its own thread, so that this many records are handled at the same time. 
Unlike a consumer group, it is not limited by the number of partitions of the 
topics."
+        type: integer
+        default: 1
+      onFailure:
+        title: On Failure
+        description: "What to do with a record whose handling failed: 
`RELEASE` gives it back to Kafka, which delivers it again, to this or another 
consumer, until the delivery limit of the broker is reached; `REJECT` drops it, 
and it is not delivered again; `ACCEPT` counts it as handled, and it is not 
delivered again."
+        type: string
+        default: "RELEASE"
+        enum: ["ACCEPT", "RELEASE", "REJECT"]
+      pollOnError:
+        title: Poll On Error Behavior
+        description: "What to do when reading from Kafka fails: 
`ERROR_HANDLER` logs the error and reads again, `DISCARD` and `RETRY` read 
again, `RECONNECT` connects again, and `STOP` stops reading until the 
integration is restarted. A record whose handling fails is not a read error: 
see `onFailure`."
+        type: string
+        default: "ERROR_HANDLER"
+        enum: ["DISCARD", "ERROR_HANDLER", "RECONNECT", "RETRY", "STOP"]
+      deserializeHeaders:
+        title: Automatically Deserialize Headers
+        description: "If true, the values of the record headers are turned 
into text. If false, they stay bytes."
+        type: boolean
+        default: true
+      schemaRegistryVendor:
+        title: Schema Registry Vendor
+        description: "The schema registry that holds the schemas of the record 
values: `confluent`, also for registries with the Confluent API such as 
Redpanda and Karapace; `apicurio` (Apicurio Registry 3.x); `aws-glue` (AWS Glue 
Schema Registry); or `azure` (Azure Schema Registry of Event Hubs). It sets the 
value deserializer and the registry properties, and its jars must be added to 
the integration (see below). Leave it unset when the records do not use a 
schema registry."
+        type: string
+        enum: ["confluent", "apicurio", "aws-glue", "azure"]
+      schemaRegistryUrl:
+        title: Schema Registry URL
+        description: "The URL of the schema registry: for `confluent` such as 
`http://localhost:8081`; for `apicurio` the URL of the registry API, such as 
`http://localhost:8080/apis/registry/v3`; for `azure` the fully qualified name 
of the Event Hubs namespace, such as `my-namespace.servicebus.windows.net`. 
Required when `schemaRegistryVendor` is set, except for `aws-glue`, where it 
can override the endpoint of the Glue service."
+        type: string
+        pattern: "^(https?://)?[^\\s]+$"
+      schemaRegistryRegion:
+        title: Schema Registry Region
+        description: "The AWS region of the AWS Glue Schema Registry, such as 
`eu-west-1`. When not set, the region is taken from the environment, such as 
the `AWS_REGION` variable. Only used when `schemaRegistryVendor` is `aws-glue`."
+        type: string
+      schemaRegistryName:
+        title: Schema Registry Name
+        description: "The name of the registry in AWS Glue. When not set, it 
is `default-registry`. Only used when `schemaRegistryVendor` is `aws-glue`."
+        type: string
+      schemaFormat:
+        title: Schema Format
+        description: "The format of the record values in the schema registry: 
`avro`, `json` (JSON Schema) or `protobuf` (Protocol Buffers). With `apicurio`, 
use `avro` or `protobuf`; with `azure`, use `avro`. Only used when 
`schemaRegistryVendor` is set."
+        type: string
+        enum: ["avro", "json", "protobuf"]
+        default: avro
+      schemaRegistryUsername:
+        title: Schema Registry Username
+        description: "The username to log in to a `confluent` or `apicurio` 
schema registry, with `schemaRegistryPassword`. For Confluent Cloud, the API 
key of the Schema Registry."
+        type: string
+        x-descriptors:
+          - urn:camel:group:credentials
+      schemaRegistryPassword:
+        title: Schema Registry Password
+        description: "The password of `schemaRegistryUsername`. For Confluent 
Cloud, the API secret of the Schema Registry."
+        type: string
+        format: password
+        x-descriptors:
+          - urn:camel:group:credentials
+      schemaRegistryOauthTokenEndpoint:
+        title: Schema Registry OAuth Token Endpoint
+        description: "The token endpoint of the OAuth2 server, to log in to a 
`confluent` or `apicurio` schema registry with client credentials, such as the 
token endpoint of a Keycloak realm. The URL must also be listed in the JVM 
system property `org.apache.kafka.sasl.oauthbearer.allowed.urls`, or the 
integration fails to start."
+        type: string
+        example: 
"http://keycloak:8080/realms/registry/protocol/openid-connect/token";
+      schemaRegistryOauthClientId:
+        title: Schema Registry OAuth Client ID
+        description: "The OAuth2 client id, to log in to a `confluent` or 
`apicurio` schema registry with client credentials."
+        type: string
+        x-descriptors:
+          - urn:camel:group:credentials
+      schemaRegistryOauthClientSecret:
+        title: Schema Registry OAuth Client Secret
+        description: "The OAuth2 client secret of 
`schemaRegistryOauthClientId`."
+        type: string
+        format: password
+        x-descriptors:
+          - urn:camel:group:credentials
+      schemaRegistryOauthScope:
+        title: Schema Registry OAuth Scope
+        description: "The OAuth2 scope to ask for when logging in to the 
schema registry with client credentials (optional)."
+        type: string
+  dataTypes:
+    # No 'default:' here on purpose, as in kafka-source: the body is text, or 
JSON text with
+    # `schemaRegistryVendor`, or no body for a tombstone. See #3117.
+    out:
+      headers:
+        kafka-topic:
+          title: Kafka Topic
+          description: "The topic the record was read from."
+          type: string
+        kafka-key:
+          title: Kafka Key
+          description: "The key of the record. Not set when the record has no 
key."
+          type: string
+        kafka-partition:
+          title: Kafka Partition
+          description: "The number of the partition the record was read from."
+          type: integer
+        kafka-offset:
+          title: Kafka Offset
+          description: "The position of the record in its partition."
+          type: integer
+        kafka-timestamp:
+          title: Kafka Timestamp
+          description: "The time of the record, in milliseconds since 
1970-01-01 UTC."
+          type: integer
+        kafka-delivery-count:
+          title: Kafka Delivery Count
+          description: "How many times the record has been delivered, this 
time included: 1 the first time, more when it was released and delivered again."
+          type: integer
+        ce-kafkatopic:
+          title: CloudEvents Kafka Topic
+          description: "The same as `kafka-topic`."
+          type: string
+        ce-kafkakey:
+          title: CloudEvents Kafka Key
+          description: "The same as `kafka-key`."
+          type: string
+        ce-kafkapartition:
+          title: CloudEvents Kafka Partition
+          description: "The same as `kafka-partition`."
+          type: integer
+        ce-kafkaoffset:
+          title: CloudEvents Kafka Offset
+          description: "The same as `kafka-offset`."
+          type: integer
+        ce-kafkatimestamp:
+          title: CloudEvents Kafka Timestamp
+          description: "The same as `kafka-timestamp`."
+          type: integer
+        ce-kafkadeliverycount:
+          title: CloudEvents Kafka Delivery Count
+          description: "The same as `kafka-delivery-count`."
+          type: integer
+  dependencies:
+    - "camel:jackson3"
+    - "camel:kafka"
+    - "camel:kafka-share"
+    - "camel:kamelet"
+  template:
+    beans:
+      # the header deserializer of kafka-source (camel-kafka), which also 
turns a header without a value into no value
+      - name: kafkaHeaderDeserializer
+        type: "#class:org.apache.camel.component.kafka.KafkaHeaderDeserializer"
+        properties:
+          enabled: "{{deserializeHeaders}}"
+    from:
+      uri: kafka-share
+      parameters:
+        topic: "{{topic}}"
+        additionalProperties.region: "{{?schemaRegistryRegion}}"
+        additionalProperties.registry.name: "{{?schemaRegistryName}}"
+        brokers: "{{bootstrapServers}}"
+        consumersCount: "{{consumersCount}}"
+        groupId: "{{shareGroup}}"
+        oauthClientId: "{{?oauthClientId}}"
+        oauthClientSecret: "RAW({{?oauthClientSecret}})"
+        oauthScope: "{{?oauthScope}}"
+        oauthTokenEndpointUri: "{{?oauthTokenEndpointUri}}"
+        onFailure: "{{onFailure}}"
+        pollOnError: "{{pollOnError}}"
+        saslAuthType: "{{saslAuthType}}"
+        saslPassword: "RAW({{?saslPassword}})"
+        saslUsername: "{{?saslUsername}}"
+        schemaFormat: "{{schemaFormat}}"
+        schemaRegistryURL: "{{?schemaRegistryUrl}}"
+        schemaRegistryVendor: "{{?schemaRegistryVendor}}"
+        schemaRegistryUsername: "{{?schemaRegistryUsername}}"
+        schemaRegistryPassword: "RAW({{?schemaRegistryPassword}})"
+        schemaRegistryOauthTokenEndpoint: 
"{{?schemaRegistryOauthTokenEndpoint}}"
+        schemaRegistryOauthClientId: "{{?schemaRegistryOauthClientId}}"
+        schemaRegistryOauthClientSecret: 
"RAW({{?schemaRegistryOauthClientSecret}})"
+        schemaRegistryOauthScope: "{{?schemaRegistryOauthScope}}"
+        sslKeyPassword: "RAW({{?sslKeyPassword}})"
+        sslKeystoreLocation: "{{?sslKeystoreLocation}}"
+        sslKeystorePassword: "RAW({{?sslKeystorePassword}})"
+        sslTruststoreLocation: "{{?sslTruststoreLocation}}"
+        sslTruststorePassword: "RAW({{?sslTruststorePassword}})"
+      steps:
+        - process:
+            ref: "{{kafkaHeaderDeserializer}}"
+        # Kafka record metadata under names that are not Camel internals, 
plain and CloudEvents, as kafka-source does
+        - setHeader:
+            name: kafka-topic
+            expression:
+              simple:
+                expression: "${header[CamelKafkaTopic]}"
+        - setHeader:
+            name: ce-kafkatopic
+            expression:
+              simple:
+                expression: "${header[CamelKafkaTopic]}"
+        - setHeader:
+            name: kafka-key
+            expression:
+              simple:
+                expression: "${header[CamelKafkaKey]}"
+        - setHeader:
+            name: ce-kafkakey
+            expression:
+              simple:
+                expression: "${header[CamelKafkaKey]}"
+        - setHeader:
+            name: kafka-partition
+            expression:
+              simple:
+                expression: "${header[CamelKafkaPartition]}"
+        - setHeader:
+            name: ce-kafkapartition
+            expression:
+              simple:
+                expression: "${header[CamelKafkaPartition]}"
+        - setHeader:
+            name: kafka-offset
+            expression:
+              simple:
+                expression: "${header[CamelKafkaOffset]}"
+        - setHeader:
+            name: ce-kafkaoffset
+            expression:
+              simple:
+                expression: "${header[CamelKafkaOffset]}"
+        - setHeader:
+            name: kafka-timestamp
+            expression:
+              simple:
+                expression: "${header[CamelKafkaTimestamp]}"
+        - setHeader:
+            name: ce-kafkatimestamp
+            expression:
+              simple:
+                expression: "${header[CamelKafkaTimestamp]}"
+        - setHeader:
+            name: kafka-delivery-count
+            expression:
+              simple:
+                expression: "${header[CamelKafkaShareDeliveryCount]}"
+        - setHeader:
+            name: ce-kafkadeliverycount
+            expression:
+              simple:
+                expression: "${header[CamelKafkaShareDeliveryCount]}"
+        - choice:
+            when:
+              - expression:
+                  simple:
+                    expression: "'{{?schemaRegistryVendor}}' != '' && 
'{{schemaFormat}}' == 'json' && ${body} != null && ${body} !is 
'java.lang.String'"
+                steps:
+                  - marshal:
+                      json:
+                        library: Jackson
+                  - convertBodyTo:
+                      type: java.lang.String
+              # A Protobuf message becomes the JSON of the Protobuf JSON 
mapping, as in kafka-source
+              - expression:
+                  simple:
+                    expression: "'{{?schemaRegistryVendor}}' != '' && 
'{{schemaFormat}}' == 'protobuf' && ${body} != null && ${body} !is 
'java.lang.String'"
+                steps:
+                  - setBody:
+                      expression:
+                        simple:
+                          expression: 
"${bean:type:com.google.protobuf.util.JsonFormat?method=printer().omittingInsignificantWhitespace().print(${body})}"
+              - expression:
+                  simple:
+                    expression: "'{{?schemaRegistryVendor}}' != '' && ${body} 
!= null && ${body} !is 'java.lang.String'"
+                steps:
+                  - setBody:
+                      expression:
+                        simple:
+                          expression: "${body.toString()}"
+        - to:
+            uri: kamelet:sink
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 c9c960f6e..3d5fa2631 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
@@ -1349,6 +1349,16 @@
     "group" : "Actions",
     "namespace" : "Kafka",
     "provider" : "Apache Software Foundation"
+  }, {
+    "name" : "kafka-share-source",
+    "type" : "source",
+    "supportLevel" : "Preview",
+    "title" : "Kafka Share Source",
+    "summary" : "Receives each record from one or more Apache Kafka topics 
through a share group, which hands out the records like a queue: each record 
goes to one of many consumers.",
+    "description" : "Receives each record from one or more Apache Kafka topics 
through a share group, which hands out the records like a queue: each record 
goes to one of many consumers.\n\nUse it to share the work of a topic between 
many integrations or threads, more of them than the topic has partitions, such 
as orders or tasks that each take a while to handle, when the order of the 
records does not matter. To read the records in order, or to read them again 
from a given position, use  [...]
+    "group" : "Kafka",
+    "namespace" : "Kafka",
+    "provider" : "Apache Software Foundation"
   }, {
     "name" : "kafka-sink",
     "type" : "sink",
diff --git 
a/library/camel-kamelets/src/main/resources/kamelets/kafka-share-source.kamelet.yaml
 
b/library/camel-kamelets/src/main/resources/kamelets/kafka-share-source.kamelet.yaml
new file mode 100644
index 000000000..033704d96
--- /dev/null
+++ 
b/library/camel-kamelets/src/main/resources/kamelets/kafka-share-source.kamelet.yaml
@@ -0,0 +1,405 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+apiVersion: camel.apache.org/v1
+kind: Kamelet
+metadata:
+  name: kafka-share-source
+  annotations:
+    camel.apache.org/kamelet.support.level: "Preview"
+    camel.apache.org/catalog.version: "4.24.0-SNAPSHOT"
+    camel.apache.org/kamelet.icon: 
"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxOS4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiDQoJIHZpZXdCb3g9IjAgMCA1MDAgNTAwIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1MD
 [...]
+    camel.apache.org/provider: "Apache Software Foundation"
+    camel.apache.org/kamelet.group: "Kafka"
+    camel.apache.org/kamelet.namespace: "Kafka"
+  labels:
+    camel.apache.org/kamelet.type: "source"
+    camel.apache.org/kamelet.verified: "true"
+spec:
+  definition:
+    title: "Kafka Share Source"
+    description: |-
+      Receives each record from one or more Apache Kafka topics through a 
share group, which hands out the records like a queue: each record goes to one 
of many consumers.
+
+      Use it to share the work of a topic between many integrations or 
threads, more of them than the topic has partitions, such as orders or tasks 
that each take a while to handle, when the order of the records does not 
matter. To read the records in order, or to read them again from a given 
position, use `kafka-source`. Share groups are on by default from Kafka 4.2.
+
+      Output: the body is the value of the record, as text. With 
`schemaRegistryVendor`, the value is read with its schema from the registry and 
the body is JSON text, such as `{"id": 7, "item": "camel"}` for an Avro record. 
A Protobuf record is turned into JSON by the Protobuf JSON mapping, such as 
`{"id":7,"item":"camel"}`: the names of the fields are in lowerCamelCase 
(`orderNo` for `order_no`), 64-bit numbers are text, and the fields that have 
their default value, such as 0 or empty  [...]
+
+      Good to know: each record is acknowledged on its own once the 
integration has handled it, and a record that was handled is not delivered 
again. A record whose handling fails is released by default: Kafka delivers it 
again, to this or another consumer, up to `group.share.delivery.count.limit` 
times in all (5 by default, a broker setting), and then drops it. Set 
`onFailure` to `REJECT` to drop it at once, or to `ACCEPT` to count it as 
handled. To decide for one record, set the header [...]
+    required:
+      - topic
+      - bootstrapServers
+      - saslAuthType
+      - shareGroup
+    type: object
+    properties:
+      topic:
+        title: Topic Names
+        description: "The topics to read from, separated by commas. A share 
group cannot read the topics whose names match a regular expression."
+        type: string
+        example: "orders"
+      bootstrapServers:
+        title: Bootstrap Servers
+        description: "The address of one or more Kafka brokers to connect to 
first, as `host:port`, separated by commas. The other brokers of the cluster 
are found from them."
+        type: string
+        example: "broker1:9092,broker2:9092"
+      shareGroup:
+        title: Share Group
+        description: "The name of the share group. All the consumers with the 
same share group, in this and in other integrations, share the records of the 
topics: each record goes to one of them. The group remembers which records were 
handled, so that a restarted integration goes on where it stopped."
+        type: string
+        example: "order-workers"
+      saslAuthType:
+        title: Authentication Type
+        description: "How to log in to Kafka. It has no default and must be 
set. `NONE` connects with no login and no TLS, as a local Kafka expects; 
`PLAIN`, `SCRAM_SHA_256` and `SCRAM_SHA_512` log in with `saslUsername` and 
`saslPassword`; `SSL` connects over TLS and logs in with the client certificate 
in `sslKeystoreLocation`, when set; `OAUTH` logs in with the `oauth` options; 
`AWS_MSK_IAM` (Amazon MSK) and `KERBEROS` take their credentials from the 
environment the integration runs in [...]
+        type: string
+        enum: ["NONE", "PLAIN", "SCRAM_SHA_256", "SCRAM_SHA_512", "SSL", 
"OAUTH", "AWS_MSK_IAM", "KERBEROS"]
+      saslUsername:
+        title: Username
+        description: "The user name to log in to Kafka with. Required when 
`saslAuthType` is `PLAIN`, `SCRAM_SHA_256` or `SCRAM_SHA_512`."
+        type: string
+        x-descriptors:
+          - urn:camel:group:credentials
+      saslPassword:
+        title: Password
+        description: "The password of `saslUsername`. Required when 
`saslAuthType` is `PLAIN`, `SCRAM_SHA_256` or `SCRAM_SHA_512`."
+        type: string
+        format: password
+        x-descriptors:
+          - urn:camel:group:credentials
+      oauthClientId:
+        title: OAuth Client ID
+        description: "The ID of the client registered with the OAuth 2.0 
provider. Required when `saslAuthType` is `OAUTH`."
+        type: string
+      oauthClientSecret:
+        title: OAuth Client Secret
+        description: "The secret of the OAuth client `oauthClientId`, from the 
OAuth 2.0 provider. Required when `saslAuthType` is `OAUTH`."
+        type: string
+        format: password
+        x-descriptors:
+          - urn:camel:group:credentials
+      oauthTokenEndpointUri:
+        title: OAuth Token URL
+        description: "The URL of the OAuth 2.0 provider where the Kamelet gets 
its access token. Required when `saslAuthType` is `OAUTH`. The URL must also be 
listed in the JVM system property 
`org.apache.kafka.sasl.oauthbearer.allowed.urls`, or the integration fails to 
start."
+        type: string
+        example: "https://auth.example.com/oauth2/token";
+      oauthScope:
+        title: OAuth Scope
+        description: "The scope to ask the OAuth 2.0 provider for, when it 
requires one. Only used when `saslAuthType` is `OAUTH`."
+        type: string
+        example: "kafka"
+      sslTruststoreLocation:
+        title: SSL Truststore Location
+        description: "The path of a trust store file, in JKS format, with the 
certificates to trust the brokers by. Needed only when the brokers use a 
certificate that Java does not trust by default, such as a self-signed one."
+        type: string
+        example: "/etc/kafka/truststore.jks"
+      sslTruststorePassword:
+        title: SSL Truststore Password
+        description: "The password of the trust store file in 
`sslTruststoreLocation`."
+        type: string
+        format: password
+        x-descriptors:
+          - urn:camel:group:credentials
+      sslKeystoreLocation:
+        title: SSL Keystore Location
+        description: "The path of a key store file, in JKS format, with the 
certificate and private key of the client. Needed only to log in with a client 
certificate (mutual TLS), usually with `saslAuthType` `SSL`."
+        type: string
+        example: "/etc/kafka/keystore.jks"
+      sslKeystorePassword:
+        title: SSL Keystore Password
+        description: "The password of the key store file in 
`sslKeystoreLocation`."
+        type: string
+        format: password
+        x-descriptors:
+          - urn:camel:group:credentials
+      sslKeyPassword:
+        title: SSL Key Password
+        description: "The password of the private key in the key store file in 
`sslKeystoreLocation`."
+        type: string
+        format: password
+        x-descriptors:
+          - urn:camel:group:credentials
+      consumersCount:
+        title: Consumers Count
+        description: "How many consumers of the share group this Kamelet runs, 
each on its own thread, so that this many records are handled at the same time. 
Unlike a consumer group, it is not limited by the number of partitions of the 
topics."
+        type: integer
+        default: 1
+      onFailure:
+        title: On Failure
+        description: "What to do with a record whose handling failed: 
`RELEASE` gives it back to Kafka, which delivers it again, to this or another 
consumer, until the delivery limit of the broker is reached; `REJECT` drops it, 
and it is not delivered again; `ACCEPT` counts it as handled, and it is not 
delivered again."
+        type: string
+        default: "RELEASE"
+        enum: ["ACCEPT", "RELEASE", "REJECT"]
+      pollOnError:
+        title: Poll On Error Behavior
+        description: "What to do when reading from Kafka fails: 
`ERROR_HANDLER` logs the error and reads again, `DISCARD` and `RETRY` read 
again, `RECONNECT` connects again, and `STOP` stops reading until the 
integration is restarted. A record whose handling fails is not a read error: 
see `onFailure`."
+        type: string
+        default: "ERROR_HANDLER"
+        enum: ["DISCARD", "ERROR_HANDLER", "RECONNECT", "RETRY", "STOP"]
+      deserializeHeaders:
+        title: Automatically Deserialize Headers
+        description: "If true, the values of the record headers are turned 
into text. If false, they stay bytes."
+        type: boolean
+        default: true
+      schemaRegistryVendor:
+        title: Schema Registry Vendor
+        description: "The schema registry that holds the schemas of the record 
values: `confluent`, also for registries with the Confluent API such as 
Redpanda and Karapace; `apicurio` (Apicurio Registry 3.x); `aws-glue` (AWS Glue 
Schema Registry); or `azure` (Azure Schema Registry of Event Hubs). It sets the 
value deserializer and the registry properties, and its jars must be added to 
the integration (see below). Leave it unset when the records do not use a 
schema registry."
+        type: string
+        enum: ["confluent", "apicurio", "aws-glue", "azure"]
+      schemaRegistryUrl:
+        title: Schema Registry URL
+        description: "The URL of the schema registry: for `confluent` such as 
`http://localhost:8081`; for `apicurio` the URL of the registry API, such as 
`http://localhost:8080/apis/registry/v3`; for `azure` the fully qualified name 
of the Event Hubs namespace, such as `my-namespace.servicebus.windows.net`. 
Required when `schemaRegistryVendor` is set, except for `aws-glue`, where it 
can override the endpoint of the Glue service."
+        type: string
+        pattern: "^(https?://)?[^\\s]+$"
+      schemaRegistryRegion:
+        title: Schema Registry Region
+        description: "The AWS region of the AWS Glue Schema Registry, such as 
`eu-west-1`. When not set, the region is taken from the environment, such as 
the `AWS_REGION` variable. Only used when `schemaRegistryVendor` is `aws-glue`."
+        type: string
+      schemaRegistryName:
+        title: Schema Registry Name
+        description: "The name of the registry in AWS Glue. When not set, it 
is `default-registry`. Only used when `schemaRegistryVendor` is `aws-glue`."
+        type: string
+      schemaFormat:
+        title: Schema Format
+        description: "The format of the record values in the schema registry: 
`avro`, `json` (JSON Schema) or `protobuf` (Protocol Buffers). With `apicurio`, 
use `avro` or `protobuf`; with `azure`, use `avro`. Only used when 
`schemaRegistryVendor` is set."
+        type: string
+        enum: ["avro", "json", "protobuf"]
+        default: avro
+      schemaRegistryUsername:
+        title: Schema Registry Username
+        description: "The username to log in to a `confluent` or `apicurio` 
schema registry, with `schemaRegistryPassword`. For Confluent Cloud, the API 
key of the Schema Registry."
+        type: string
+        x-descriptors:
+          - urn:camel:group:credentials
+      schemaRegistryPassword:
+        title: Schema Registry Password
+        description: "The password of `schemaRegistryUsername`. For Confluent 
Cloud, the API secret of the Schema Registry."
+        type: string
+        format: password
+        x-descriptors:
+          - urn:camel:group:credentials
+      schemaRegistryOauthTokenEndpoint:
+        title: Schema Registry OAuth Token Endpoint
+        description: "The token endpoint of the OAuth2 server, to log in to a 
`confluent` or `apicurio` schema registry with client credentials, such as the 
token endpoint of a Keycloak realm. The URL must also be listed in the JVM 
system property `org.apache.kafka.sasl.oauthbearer.allowed.urls`, or the 
integration fails to start."
+        type: string
+        example: 
"http://keycloak:8080/realms/registry/protocol/openid-connect/token";
+      schemaRegistryOauthClientId:
+        title: Schema Registry OAuth Client ID
+        description: "The OAuth2 client id, to log in to a `confluent` or 
`apicurio` schema registry with client credentials."
+        type: string
+        x-descriptors:
+          - urn:camel:group:credentials
+      schemaRegistryOauthClientSecret:
+        title: Schema Registry OAuth Client Secret
+        description: "The OAuth2 client secret of 
`schemaRegistryOauthClientId`."
+        type: string
+        format: password
+        x-descriptors:
+          - urn:camel:group:credentials
+      schemaRegistryOauthScope:
+        title: Schema Registry OAuth Scope
+        description: "The OAuth2 scope to ask for when logging in to the 
schema registry with client credentials (optional)."
+        type: string
+  dataTypes:
+    # No 'default:' here on purpose, as in kafka-source: the body is text, or 
JSON text with
+    # `schemaRegistryVendor`, or no body for a tombstone. See #3117.
+    out:
+      headers:
+        kafka-topic:
+          title: Kafka Topic
+          description: "The topic the record was read from."
+          type: string
+        kafka-key:
+          title: Kafka Key
+          description: "The key of the record. Not set when the record has no 
key."
+          type: string
+        kafka-partition:
+          title: Kafka Partition
+          description: "The number of the partition the record was read from."
+          type: integer
+        kafka-offset:
+          title: Kafka Offset
+          description: "The position of the record in its partition."
+          type: integer
+        kafka-timestamp:
+          title: Kafka Timestamp
+          description: "The time of the record, in milliseconds since 
1970-01-01 UTC."
+          type: integer
+        kafka-delivery-count:
+          title: Kafka Delivery Count
+          description: "How many times the record has been delivered, this 
time included: 1 the first time, more when it was released and delivered again."
+          type: integer
+        ce-kafkatopic:
+          title: CloudEvents Kafka Topic
+          description: "The same as `kafka-topic`."
+          type: string
+        ce-kafkakey:
+          title: CloudEvents Kafka Key
+          description: "The same as `kafka-key`."
+          type: string
+        ce-kafkapartition:
+          title: CloudEvents Kafka Partition
+          description: "The same as `kafka-partition`."
+          type: integer
+        ce-kafkaoffset:
+          title: CloudEvents Kafka Offset
+          description: "The same as `kafka-offset`."
+          type: integer
+        ce-kafkatimestamp:
+          title: CloudEvents Kafka Timestamp
+          description: "The same as `kafka-timestamp`."
+          type: integer
+        ce-kafkadeliverycount:
+          title: CloudEvents Kafka Delivery Count
+          description: "The same as `kafka-delivery-count`."
+          type: integer
+  dependencies:
+    - "camel:jackson3"
+    - "camel:kafka"
+    - "camel:kafka-share"
+    - "camel:kamelet"
+  template:
+    beans:
+      # the header deserializer of kafka-source (camel-kafka), which also 
turns a header without a value into no value
+      - name: kafkaHeaderDeserializer
+        type: "#class:org.apache.camel.component.kafka.KafkaHeaderDeserializer"
+        properties:
+          enabled: "{{deserializeHeaders}}"
+    from:
+      uri: kafka-share
+      parameters:
+        topic: "{{topic}}"
+        additionalProperties.region: "{{?schemaRegistryRegion}}"
+        additionalProperties.registry.name: "{{?schemaRegistryName}}"
+        brokers: "{{bootstrapServers}}"
+        consumersCount: "{{consumersCount}}"
+        groupId: "{{shareGroup}}"
+        oauthClientId: "{{?oauthClientId}}"
+        oauthClientSecret: "RAW({{?oauthClientSecret}})"
+        oauthScope: "{{?oauthScope}}"
+        oauthTokenEndpointUri: "{{?oauthTokenEndpointUri}}"
+        onFailure: "{{onFailure}}"
+        pollOnError: "{{pollOnError}}"
+        saslAuthType: "{{saslAuthType}}"
+        saslPassword: "RAW({{?saslPassword}})"
+        saslUsername: "{{?saslUsername}}"
+        schemaFormat: "{{schemaFormat}}"
+        schemaRegistryURL: "{{?schemaRegistryUrl}}"
+        schemaRegistryVendor: "{{?schemaRegistryVendor}}"
+        schemaRegistryUsername: "{{?schemaRegistryUsername}}"
+        schemaRegistryPassword: "RAW({{?schemaRegistryPassword}})"
+        schemaRegistryOauthTokenEndpoint: 
"{{?schemaRegistryOauthTokenEndpoint}}"
+        schemaRegistryOauthClientId: "{{?schemaRegistryOauthClientId}}"
+        schemaRegistryOauthClientSecret: 
"RAW({{?schemaRegistryOauthClientSecret}})"
+        schemaRegistryOauthScope: "{{?schemaRegistryOauthScope}}"
+        sslKeyPassword: "RAW({{?sslKeyPassword}})"
+        sslKeystoreLocation: "{{?sslKeystoreLocation}}"
+        sslKeystorePassword: "RAW({{?sslKeystorePassword}})"
+        sslTruststoreLocation: "{{?sslTruststoreLocation}}"
+        sslTruststorePassword: "RAW({{?sslTruststorePassword}})"
+      steps:
+        - process:
+            ref: "{{kafkaHeaderDeserializer}}"
+        # Kafka record metadata under names that are not Camel internals, 
plain and CloudEvents, as kafka-source does
+        - setHeader:
+            name: kafka-topic
+            expression:
+              simple:
+                expression: "${header[CamelKafkaTopic]}"
+        - setHeader:
+            name: ce-kafkatopic
+            expression:
+              simple:
+                expression: "${header[CamelKafkaTopic]}"
+        - setHeader:
+            name: kafka-key
+            expression:
+              simple:
+                expression: "${header[CamelKafkaKey]}"
+        - setHeader:
+            name: ce-kafkakey
+            expression:
+              simple:
+                expression: "${header[CamelKafkaKey]}"
+        - setHeader:
+            name: kafka-partition
+            expression:
+              simple:
+                expression: "${header[CamelKafkaPartition]}"
+        - setHeader:
+            name: ce-kafkapartition
+            expression:
+              simple:
+                expression: "${header[CamelKafkaPartition]}"
+        - setHeader:
+            name: kafka-offset
+            expression:
+              simple:
+                expression: "${header[CamelKafkaOffset]}"
+        - setHeader:
+            name: ce-kafkaoffset
+            expression:
+              simple:
+                expression: "${header[CamelKafkaOffset]}"
+        - setHeader:
+            name: kafka-timestamp
+            expression:
+              simple:
+                expression: "${header[CamelKafkaTimestamp]}"
+        - setHeader:
+            name: ce-kafkatimestamp
+            expression:
+              simple:
+                expression: "${header[CamelKafkaTimestamp]}"
+        - setHeader:
+            name: kafka-delivery-count
+            expression:
+              simple:
+                expression: "${header[CamelKafkaShareDeliveryCount]}"
+        - setHeader:
+            name: ce-kafkadeliverycount
+            expression:
+              simple:
+                expression: "${header[CamelKafkaShareDeliveryCount]}"
+        - choice:
+            when:
+              - expression:
+                  simple:
+                    expression: "'{{?schemaRegistryVendor}}' != '' && 
'{{schemaFormat}}' == 'json' && ${body} != null && ${body} !is 
'java.lang.String'"
+                steps:
+                  - marshal:
+                      json:
+                        library: Jackson
+                  - convertBodyTo:
+                      type: java.lang.String
+              # A Protobuf message becomes the JSON of the Protobuf JSON 
mapping, as in kafka-source
+              - expression:
+                  simple:
+                    expression: "'{{?schemaRegistryVendor}}' != '' && 
'{{schemaFormat}}' == 'protobuf' && ${body} != null && ${body} !is 
'java.lang.String'"
+                steps:
+                  - setBody:
+                      expression:
+                        simple:
+                          expression: 
"${bean:type:com.google.protobuf.util.JsonFormat?method=printer().omittingInsignificantWhitespace().print(${body})}"
+              - expression:
+                  simple:
+                    expression: "'{{?schemaRegistryVendor}}' != '' && ${body} 
!= null && ${body} !is 'java.lang.String'"
+                steps:
+                  - setBody:
+                      expression:
+                        simple:
+                          expression: "${body.toString()}"
+        - to:
+            uri: kamelet:sink
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-share-schema-registry-route.citrus.it.yaml
 
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-share-schema-registry-route.citrus.it.yaml
new file mode 100644
index 000000000..197362b8e
--- /dev/null
+++ 
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-share-schema-registry-route.citrus.it.yaml
@@ -0,0 +1,96 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+name: kafka-share-schema-registry-route-test
+variables:
+  - name: "kafka.topic"
+    value: "share-protobuf"
+  - name: "kafka.share.group"
+    value: "share-protobuf-group"
+actions:
+  # Apache Kafka 4 with share groups, see kafka-share-source-route, and 
Apicurio Registry 3.x as the schema registry
+  - testcontainers:
+      start:
+        kafka:
+          implementation: "apache"
+          version: "4.4.0"
+          topics:
+            - "${kafka.topic}"
+          env:
+            - name: "KAFKA_SHARE_COORDINATOR_STATE_TOPIC_REPLICATION_FACTOR"
+              value: "1"
+            - name: "KAFKA_SHARE_COORDINATOR_STATE_TOPIC_MIN_ISR"
+              value: "1"
+  - testcontainers:
+      start:
+        container:
+          name: "apicurio"
+          image: "apicurio/apicurio-registry:3.3.4"
+          autoRemove: true
+          startUpTimeout: 120
+          exposedPorts:
+            - 8080
+          waitFor:
+            logMessage: '.*Listening on.*'
+
+  - createVariables:
+      variables:
+        - name: "kafka.bootstrapServers"
+          value: "${CITRUS_TESTCONTAINERS_KAFKA_BOOTSTRAP_SERVERS}"
+  - groovy:
+      script:
+        file: "kafka/share-group-earliest.groovy"
+
+  - camel:
+      cli:
+        run:
+          integration:
+            file: "kafka/kafka-share-schema-registry-route.yaml"
+            systemProperties:
+              properties:
+                - name: kafka.topic
+                  value: "${kafka.topic}"
+                - name: kafka.share.group
+                  value: "${kafka.share.group}"
+                - name: kafka.bootstrapServers
+                  value: "${kafka.bootstrapServers}"
+                - name: kafka.schemaRegistryUrl
+                  value: 
"http://${CITRUS_TESTCONTAINERS_APICURIO_HOST}:${CITRUS_TESTCONTAINERS_APICURIO_PORT}/apis/registry/v3";
+                - name: http.sink.url
+                  value: "http://localhost:${kafka.sink.server.port}/result";
+
+  # kafka-sink writes the Protobuf message, kafka-share-source reads it and 
gives it as JSON text
+  - http:
+      server: "kafkaSinkServer"
+      receiveRequest:
+        POST:
+          path: "/result"
+          type: "plaintext"
+          headers:
+            - name: "X-Body-Type"
+              value: "java.lang.String"
+            - name: "kafka-topic"
+              value: "${kafka.topic}"
+          body:
+            data: '{"id":1,"item":"camel"}'
+  - http:
+      server: "kafkaSinkServer"
+      sendResponse:
+        response:
+          status: 200
+          reasonPhrase: "OK"
+          version: "HTTP/1.1"
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-share-schema-registry-route.yaml
 
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-share-schema-registry-route.yaml
new file mode 100644
index 000000000..6d3c196ea
--- /dev/null
+++ 
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-share-schema-registry-route.yaml
@@ -0,0 +1,58 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+# kafka-sink writes a Protobuf message through the schema registry, with 
schemaFormat protobuf
+- route:
+    from:
+      uri: "timer:records"
+      parameters:
+        period: "1000"
+        repeatCount: 1
+      steps:
+        - setBody:
+            constant: '{"id":1,"item":"camel"}'
+        - to:
+            uri: "kamelet:protobuf-message-action"
+            parameters:
+              schema: 'syntax = "proto3"; message Order { int32 id = 1; string 
item = 2; }'
+        - to:
+            uri: "kamelet:kafka-sink"
+            parameters:
+              bootstrapServers: '{{kafka.bootstrapServers}}'
+              saslAuthType: NONE
+              topic: '{{kafka.topic}}'
+              schemaRegistryVendor: apicurio
+              schemaRegistryUrl: '{{kafka.schemaRegistryUrl}}'
+              schemaFormat: protobuf
+# kafka-share-source reads it with its schema from the registry
+- route:
+    from:
+      uri: "kamelet:kafka-share-source"
+      parameters:
+        bootstrapServers: '{{kafka.bootstrapServers}}'
+        saslAuthType: NONE
+        topic: '{{kafka.topic}}'
+        shareGroup: '{{kafka.share.group}}'
+        schemaRegistryVendor: apicurio
+        schemaRegistryUrl: '{{kafka.schemaRegistryUrl}}'
+        schemaFormat: protobuf
+      steps:
+        - setHeader:
+            name: X-Body-Type
+            simple: "${body.getClass().getName()}"
+        - to:
+            uri: "{{http.sink.url}}"
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-share-source-route.citrus.it.yaml
 
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-share-source-route.citrus.it.yaml
new file mode 100644
index 000000000..1f4d7e3bd
--- /dev/null
+++ 
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-share-source-route.citrus.it.yaml
@@ -0,0 +1,236 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+name: kafka-share-source-route-test
+variables:
+  - name: "kafka.topic"
+    value: "share-topic"
+  - name: "kafka.share.group"
+    value: "share-group"
+  - name: "kafka.source"
+    value: "Kafka share Kamelet source"
+  - name: "kafka.message.key"
+    value: "citrus:randomNumber(4)"
+  - name: "kafka.message"
+    value: "Camel rocks!"
+actions:
+  # Apache Kafka 4, where share groups are on. A single broker must keep the 
state of the share groups
+  # with a replication factor of 1, or the share groups get no records.
+  - testcontainers:
+      start:
+        kafka:
+          implementation: "apache"
+          version: "4.4.0"
+          topics:
+            - "${kafka.topic}"
+          env:
+            - name: "KAFKA_SHARE_COORDINATOR_STATE_TOPIC_REPLICATION_FACTOR"
+              value: "1"
+            - name: "KAFKA_SHARE_COORDINATOR_STATE_TOPIC_MIN_ISR"
+              value: "1"
+
+  - createVariables:
+      variables:
+        - name: "kafka.bootstrapServers"
+          value: "${CITRUS_TESTCONTAINERS_KAFKA_BOOTSTRAP_SERVERS}"
+  - groovy:
+      script:
+        file: "kafka/share-group-earliest.groovy"
+
+  - camel:
+      cli:
+        run:
+          integration:
+            file: "kafka/kafka-share-source-route.yaml"
+            systemProperties:
+              properties:
+                - name: "kafka.topic"
+                  value: "${kafka.topic}"
+                - name: "kafka.share.group"
+                  value: "${kafka.share.group}"
+                - name: "kafka.bootstrapServers"
+                  value: "${kafka.bootstrapServers}"
+                - name: "http.sink.url"
+                  value: "http://localhost:${kafka.sink.server.port}/result";
+
+  - createEndpoint:
+      name: kafkaShareProducer
+      type: "kafka"
+      autoClose: true
+      properties:
+        topic: "${kafka.topic}"
+        server: "${kafka.bootstrapServers}"
+
+  # A record: its value, key and headers
+  - send:
+      endpoint: kafkaShareProducer
+      message:
+        headers:
+          - name: "event-source"
+            value: "${kafka.source}"
+          - name: "citrus_kafka_messageKey"
+            value: "${kafka.message.key}"
+        body:
+          data: "${kafka.message}"
+  - http:
+      server: "kafkaSinkServer"
+      receiveRequest:
+        POST:
+          path: "/result"
+          type: "plaintext"
+          headers:
+            - name: "event-source"
+              value: "${kafka.source}"
+            - name: "X-Body-Type"
+              value: "java.lang.String"
+            - name: "kafka-topic"
+              value: "${kafka.topic}"
+            - name: "ce-kafkatopic"
+              value: "${kafka.topic}"
+            - name: "kafka-key"
+              value: "${kafka.message.key}"
+            - name: "ce-kafkakey"
+              value: "${kafka.message.key}"
+            - name: "kafka-partition"
+              value: "0"
+            - name: "kafka-offset"
+              value: "0"
+            - name: "kafka-timestamp"
+              value: "@isNumber()@"
+            - name: "kafka-delivery-count"
+              value: "1"
+            - name: "ce-kafkadeliverycount"
+              value: "1"
+          body:
+            data: "${kafka.message}"
+  - http:
+      server: "kafkaSinkServer"
+      sendResponse:
+        response:
+          status: 200
+          reasonPhrase: "OK"
+          version: "HTTP/1.1"
+
+  # A record whose handling fails is released and delivered again. Its record 
header
+  # CamelKafkaShareAcknowledge is not used: with ACCEPT it would not be 
delivered again.
+  - send:
+      endpoint: kafkaShareProducer
+      message:
+        headers:
+          - name: "CamelKafkaShareAcknowledge"
+            value: "ACCEPT"
+        body:
+          data: "fail"
+  - http:
+      server: "kafkaSinkServer"
+      receiveRequest:
+        POST:
+          path: "/result"
+          type: "plaintext"
+          headers:
+            - name: "kafka-offset"
+              value: "1"
+            - name: "kafka-delivery-count"
+              value: "2"
+          body:
+            data: "fail"
+  - http:
+      server: "kafkaSinkServer"
+      sendResponse:
+        response:
+          status: 200
+          reasonPhrase: "OK"
+          version: "HTTP/1.1"
+
+  # A record that the integration releases with the header 
CamelKafkaShareAcknowledge is delivered again
+  - send:
+      endpoint: kafkaShareProducer
+      message:
+        body:
+          data: "release"
+  - http:
+      server: "kafkaSinkServer"
+      receiveRequest:
+        POST:
+          path: "/result"
+          type: "plaintext"
+          headers:
+            - name: "kafka-offset"
+              value: "2"
+            - name: "kafka-delivery-count"
+              value: "2"
+          body:
+            data: "release"
+  - http:
+      server: "kafkaSinkServer"
+      sendResponse:
+        response:
+          status: 200
+          reasonPhrase: "OK"
+          version: "HTTP/1.1"
+
+  # Two consumers of one share group: the first consumer waits for the answer 
to its record, which is
+  # not sent, so the next record goes to the second consumer. The answer to 
the last request is sent.
+  - send:
+      endpoint: kafkaShareProducer
+      message:
+        body:
+          data: "one"
+  - http:
+      server: "kafkaSinkServer"
+      receiveRequest:
+        POST:
+          path: "/result"
+          type: "plaintext"
+          body:
+            data: "one"
+        extract:
+          header:
+            - name: "X-Consumer"
+              variable: "first.consumer"
+  - send:
+      endpoint: kafkaShareProducer
+      message:
+        body:
+          data: "two"
+  - http:
+      server: "kafkaSinkServer"
+      receiveRequest:
+        POST:
+          path: "/result"
+          type: "plaintext"
+          body:
+            data: "two"
+        extract:
+          header:
+            - name: "X-Consumer"
+              variable: "second.consumer"
+  - http:
+      server: "kafkaSinkServer"
+      sendResponse:
+        response:
+          status: 200
+          reasonPhrase: "OK"
+          version: "HTTP/1.1"
+  - groovy:
+      script:
+        value: |
+          def first = context.getVariable('first.consumer')
+          def second = context.getVariable('second.consumer')
+          if (first == second) {
+              throw new 
org.citrusframework.exceptions.ValidationException('Both records went to the 
consumer ' + first)
+          }
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-share-source-route.yaml
 
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-share-source-route.yaml
new file mode 100644
index 000000000..e8b9b0169
--- /dev/null
+++ 
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-share-source-route.yaml
@@ -0,0 +1,51 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+# Two consumers of one share group, on their own threads
+- route:
+    from:
+      uri: "kamelet:kafka-share-source"
+      parameters:
+        bootstrapServers: '{{kafka.bootstrapServers}}'
+        topic: '{{kafka.topic}}'
+        shareGroup: '{{kafka.share.group}}'
+        saslAuthType: 'NONE'
+        consumersCount: 2
+      steps:
+        - setHeader:
+            name: X-Consumer
+            simple: "${threadName}"
+        - setHeader:
+            name: X-Body-Type
+            simple: "${body.getClass().getName()}"
+        - choice:
+            when:
+              # the record "fail" fails the first time it is delivered, so it 
is released and delivered again
+              - simple: "${body} == 'fail' && ${header.kafka-delivery-count} 
== 1"
+                steps:
+                  - throwException:
+                      exceptionType: "java.lang.IllegalStateException"
+                      message: "Failed on the first delivery"
+              # the record "release" is released by the header the first time 
it is delivered
+              - simple: "${body} == 'release' && 
${header.kafka-delivery-count} == 1"
+                steps:
+                  - setHeader:
+                      name: CamelKafkaShareAcknowledge
+                      constant: RELEASE
+                  - stop: {}
+        - to:
+            uri: "{{http.sink.url}}"
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/kafka/share-group-earliest.groovy
 
b/tests/camel-kamelets-itest/src/test/resources/kafka/share-group-earliest.groovy
new file mode 100644
index 000000000..167c5b3ab
--- /dev/null
+++ 
b/tests/camel-kamelets-itest/src/test/resources/kafka/share-group-earliest.groovy
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// A new share group starts at the newest records. Set the group configuration 
share.auto.offset.reset
+// to earliest before the group first reads, so that the test does not depend 
on when the share consumers
+// have joined the group: the records can be sent as soon as the integration 
is started.
+//
+//  - kafka.bootstrapServers: the Kafka broker
+//  - kafka.share.group:      the name of the share group
+
+import org.apache.kafka.clients.admin.Admin
+import org.apache.kafka.clients.admin.AdminClientConfig
+import org.apache.kafka.clients.admin.AlterConfigOp
+import org.apache.kafka.clients.admin.ConfigEntry
+import org.apache.kafka.common.config.ConfigResource
+
+import java.util.concurrent.TimeUnit
+
+def servers = context.getVariable('kafka.bootstrapServers')
+def group = context.getVariable('kafka.share.group')
+
+def admin = Admin.create([(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG): 
servers])
+try {
+    def resource = new ConfigResource(ConfigResource.Type.GROUP, group)
+    def op = new AlterConfigOp(new ConfigEntry('share.auto.offset.reset', 
'earliest'), AlterConfigOp.OpType.SET)
+    admin.incrementalAlterConfigs([(resource): [op]]).all().get(30, 
TimeUnit.SECONDS)
+} finally {
+    admin.close()
+}

Reply via email to