NIFI-15961 - Add Kafka share-group support to ConsumeKafka - #11271
pvillard31 wants to merge 2 commits into
Conversation
067bd83 to
d897a97
Compare
|
I rebased on latest and I'll add Kafka Share-Group backlog reporting as a follow-up item. |
|
sorry @pvillard31 looks like it needs another rebase and conflict resolution. I'm happy to dig in and review/test. Seems like a cool new feature |
Introduce share-group consumption for ConsumeKafka backed by Kafka 4.2's GA share consumer (KIP-932). A new "Group Type" property selects between the existing classic Consumer Group code path (default; preserves all prior behavior) and the new Share Group path, and a new "Acknowledgement Mode" property gates per-record vs. implicit acknowledgement when the share-group path is selected. - New KafkaShareConsumerService API contract plus Kafka4ShareConsumerService implementation wrapping org.apache.kafka.clients.consumer.ShareConsumer. - KafkaConnectionService gains a default getShareConsumerService() so third-party connection services remain ABI-compatible and only opt in when they support share groups. - Kafka3ConnectionService strips the classic-consumer properties rejected by ShareConsumerConfig.SHARE_GROUP_UNSUPPORTED_CONFIGS before constructing the share consumer. - ConsumeKafka.verify() exercises a share-group subscription and releases any sampled records back to the share group. - Bump the integration-test broker to apache/kafka:4.2.0 (the version that matches the bundled kafka-clients and the first release where share groups are GA). - Add unit tests for the share-consumer service (poll, explicit/implicit ack, commit, rollback, close, tombstone handling), the processor's share-group selection/verification/ack-mode wiring, and an integration test ConsumeKafkaShareGroupIT. Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>
d897a97 to
ae1393f
Compare
|
thanks @joewitt , rebased |
|
Thanks
What was true before the PR What is true with the PR What I propose specifically and why
What was true before the PR What is true with the PR What I propose specifically and why |
|
Unsupported share-consumer configs (hand-copied deny list) What was true before the PR
Classic What is true with the PR Share Group reuses that same bag to construct
That check is new with share groups. It is client-side, before any broker call. It is not a cluster rule that old brokers started enforcing. Because the shared bag always contains This does not couple the default ConsumeKafka path to a Kafka broker version. What I propose specifically and why Do not try to call Kafka’s constant from production code; it is not part of the public API. Keep the hardcoded Add a unit test that reads Kafka’s list by reflection and asserts every key is gone after the helper runs: Class<?> clazz = Class.forName("org.apache.kafka.clients.consumer.ShareConsumerConfig");
Field field = clazz.getDeclaredField("SHARE_GROUP_UNSUPPORTED_CONFIGS");
field.setAccessible(true);
@SuppressWarnings("unchecked")
List<String> kafkaUnsupported = (List<String>) field.get(null);
Properties properties = new Properties();
for (String key : kafkaUnsupported) {
properties.put(key, "placeholder");
}
stripShareUnsupportedConsumerConfigs(properties);
assertTrue(kafkaUnsupported.stream().noneMatch(properties::containsKey),
"Share consumer still carries keys Kafka rejects: " + properties.keySet());That test fails on the next kafka-clients bump that adds a rejected key, instead of failing when someone enables Share Group. Over-stripping (we remove a key Kafka later allows) is the remaining drift; that is acceptable compared with constructor failure, and the same test makes the mismatch visible when the Kafka list changes. Also drop the “Kafka 4.2+” wording on this block. The reject list is defined by the kafka-clients jar NiFi compiles against (4.3.1 here), not by the broker version in the field. |
|
What was true before the PR
What is true with the PR Share ITs use that same 4.3.1 image. What actually changed is broker config on that image so share groups work: share in The PR body still has a bullet: “Bump the integration-test broker to apache/kafka:4.2.0”. That reads as either a version bump that did not happen or a downgrade from 4.3.1 to 4.2.0. The share product requirement (4.1+ / 4.2+ GA brokers in the field) is a different statement and is already in What I propose specifically and why Fix the PR summary bullet (and any leftover “we bumped ITs to 4.2.0” comments) to say: clients and Testcontainers stay on 4.3.1; this change only enables share on that broker. Otherwise reviewers will think the Kafka test matrix moved, and it did not. Broker 4.2 as the minimum for Share Group in production can stay in processor docs; that is KIP-932 GA, not the Docker tag used in CI. |
|
Thanks @joewitt for the detailed review. I pushed
|
Summary
NIFI-15961 - Add Kafka share-group support to ConsumeKafka
Introduce share-group consumption for ConsumeKafka backed by Kafka 4.2's GA share consumer (KIP-932). A new "Group Type" property selects between the existing classic Consumer Group code path (default; preserves all prior behavior) and the new Share Group path, and a new "Acknowledgement Mode" property gates per-record vs. implicit acknowledgement when the share-group path is selected.
KafkaShareConsumerServiceAPI contract andKafka4ShareConsumerServiceimplementation wrappingorg.apache.kafka.clients.consumer.ShareConsumer.KafkaConnectionService.getShareConsumerService()method so third-party connection services remain compatible and opt in to Share Group support explicitly.KafkaShareConsumerbefore constructing the share consumer, with focused behavioral coverage for the known unsupported properties.ConsumeKafka.verify()to exercise a Share Group subscription and release sampled records back to the group.kafka-clientsand the Testcontainers image on 4.3.1; enable Share Group broker configuration on that existing image for integration tests.Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000VerifiedstatusPull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
./mvnw clean install -P contrib-checkFocused Verification
Kafka3ConnectionServiceTestandKafka4ShareConsumerServiceTest: 24 tests passedConsumeKafkaTest: 20 tests passedConsumeKafkaShareGroupIT: 4 tests passednifi-kafka-3-integrationmodule: 132 tests passed, 6 skipped-Pcontrib-checkLicensing
LICENSEandNOTICEfilesDocumentation