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

   A new source Kamelet, `kafka-share-source`, on the Camel `kafka-share` 
component (Preview, since 4.23). It reads Kafka topics through a share group 
(KIP-932, Queues for Kafka): each record goes to one of many consumers, and 
there can be more consumers than partitions. Support level "Preview", like the 
component.
   
   ## Options
   
   - Required: `topic` (comma-separated, no patterns: share groups do not 
support them), `bootstrapServers`, `saslAuthType`, `shareGroup` (the `groupId` 
of the component, which it requires).
   - Security, the same as `kafka-source`: `saslUsername`/`saslPassword`, 
`oauthClientId`/`oauthClientSecret`/`oauthTokenEndpointUri`/`oauthScope`, 
`sslTruststoreLocation`/`sslTruststorePassword`, 
`sslKeystoreLocation`/`sslKeystorePassword`, `sslKeyPassword`. The secrets are 
`format: password` with the credentials descriptor, and are passed with `RAW()`.
   - Share group: `consumersCount` (default 1) and `onFailure` (`RELEASE` by 
default, or `REJECT`/`ACCEPT`).
   - The same as `kafka-source`: `pollOnError` (described the way kafka-share 
handles it), `deserializeHeaders`, and the schema registry options 
(`schemaRegistryVendor`, `schemaRegistryUrl`, `schemaFormat`, the region/name 
of AWS Glue, and the basic and OAuth2 logins). kafka-share supports 
`schemaRegistryVendor`.
   - Left out because a share group has no such thing: `autoOffsetReset`, 
`autoCommitEnable`, `allowManualCommit`, `topicIsPattern`.
   
   ## Input / Output
   
   Output: the body is the value of the record as text (JSON text with a schema 
registry, and Protobuf goes through the Protobuf JSON mapping, as in 
`kafka-source`). A tombstone gives no body. The headers are `kafka-topic`, 
`kafka-key`, `kafka-partition`, `kafka-offset`, `kafka-timestamp` and the new 
`kafka-delivery-count`, each also as `ce-kafka*`, plus the `CamelKafka*` 
headers and the record headers (as text unless `deserializeHeaders` is false). 
The template is the same as `kafka-source`, with the `kafka-share` endpoint 
instead.
   
   Acknowledgement, checked with `camel run` and the tests:
   - a record that was handled is accepted and not delivered again;
   - a record whose handling fails is released, and delivered again with 
`kafka-delivery-count` 2, up to 5 times in all (the broker limit), and then 
dropped;
   - with `onFailure: REJECT` it is not delivered again;
   - the integration can set `CamelKafkaShareAcknowledge` 
(`ACCEPT`/`RELEASE`/`REJECT`) for one record. A record header with that name is 
filtered out, so the data cannot choose its own acknowledgement;
   - a record that takes longer than the record lock of the broker is also 
delivered to another consumer.
   
   The description also says that a new share group starts at the newest 
records, unless `share.auto.offset.reset=earliest` is set on the group first, 
and which broker settings a single broker needs (without them the group gets no 
records and logs no error).
   
   ## Tests
   
   In the `kafka` package (`KafkaIT`), against `apache/kafka:4.4.0` (pulled 
through mirror.gcr.io) with the share coordinator state topic at replication 
factor 1. Before the integration starts, a small Groovy script 
(`kafka/share-group-earliest.groovy`) sets `share.auto.offset.reset=earliest` 
on the group through the Kafka Admin client, so the test does not depend on 
when the consumers have joined.
   
   - `kafka-share-source-route`: `consumersCount: 2`.
     - One record: checks the body, its type (`String`), the key, the topic, 
partition, offset, timestamp and delivery-count headers (plain and `ce-`), and 
a record header.
     - A record that fails in the route on its first delivery comes back with 
`kafka-delivery-count` 2. It also has a record header 
`CamelKafkaShareAcknowledge: ACCEPT`, which must be ignored.
     - A record that the route releases with `CamelKafkaShareAcknowledge: 
RELEASE` comes back with `kafka-delivery-count` 2.
     - Two consumers: the first consumer is held on an HTTP request that is not 
answered, and the next record must go to the other consumer, which the test 
checks by thread name. With `consumersCount: 1` this check fails, as it should.
   - `kafka-share-schema-registry-route`: `kafka-sink` writes a Protobuf record 
through Apicurio Registry 3.3.4, and `kafka-share-source` reads it as the JSON 
text `{"id":1,"item":"camel"}`.
   
   Local results: `./mvnw -o clean install -DskipITs` passes. `KafkaIT`: the 
two new tests passed in every run, alone and in the full class (16 tests). In 
the two full runs, `kafka-manual-commit-action-route` and `kafka-source-route` 
failed. Redpanda gave `KAFKA_STORAGE_ERROR` ("Disk error when trying to access 
log file") because the Docker VM of this machine was 99% full, so the cause is 
the machine, not this change. Both tests pass when run alone, and all 14 
existing tests passed in a run without the new files.
   
   Fixes #3331.
   
   ## Upgrade note
   
   ```
   * New `kafka-share-source` Kamelet (Preview): reads Kafka topics through a 
share group (KIP-932, Kafka 4.2 or newer), so that many consumers, more than 
the partitions, share the records like a queue; each record is acknowledged on 
its own, and one whose handling fails is delivered again (`onFailure`, 
`kafka-delivery-count`).
   ```
   
   _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