atiaomar1978-hub opened a new pull request, #25844: URL: https://github.com/apache/camel/pull/25844
## Summary Fixes [CAMEL-24473](https://issues.apache.org/jira/browse/CAMEL-24473): the Kafka consumer readiness health check reported **UP** when the broker was down under `group.protocol=consumer` (KIP-848 / `AsyncKafkaConsumer`). ## Problem `KafkaFetchRecords.isReady()` used reflection to reach `ClassicKafkaConsumer.client` (`ConsumerNetworkClient.hasReadyNodes()`). Under the new consumer group protocol, `KafkaConsumer.delegate` is an `AsyncKafkaConsumer` with a different internal layout (`applicationEventHandler → networkThread → networkClientDelegate → client`). Reflection failed with `NoSuchFieldException`, the exception was swallowed, and readiness incorrectly stayed **UP**. ## Solution - Introduce `KafkaNetworkHealthHelper` to resolve network readiness for both classic and async consumer delegates - Fail closed when a real `KafkaConsumer` delegate layout cannot be resolved (conservative / fail-safe per JIRA) - Preserve legacy fail-open behavior for custom `Consumer` / `Producer` implementations - Producer path refactored into the helper without changing fail-open semantics on reflection errors ## Files changed | File | Change | |------|--------| | `KafkaNetworkHealthHelper.java` | New helper with classic + async reflection paths | | `KafkaFetchRecords.java` | Delegate readiness to helper | | `KafkaProducer.java` | Delegate readiness to helper | | `KafkaNetworkHealthHelperTest.java` | Unit tests incl. real classic/async client layout probes | | `KafkaConsumerGroupProtocolHealthCheckIT.java` | Integration test for `groupProtocol=consumer` readiness UP/DOWN | ## Testing ```bash ./mvnw -pl components/camel-kafka test -Dtest=KafkaNetworkHealthHelperTest ``` Integration test `KafkaConsumerGroupProtocolHealthCheckIT` runs when the broker supports `group.version >= 1` (Kafka 4.0+). ## Review - **Bugbot:** no bugs found - **Grok review:** feedback addressed (fail-open for custom clients/producers, null guards on async chain, real-client unit tests) _AI-generated PR description on behalf of atiaomar1978-hub_ -- 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]
