spring-cloud / spring-cloud/spring-cloud-stream

AdminClient / KafkaAdmin with merged standard kafka and binder properties

Open
#2,322 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

KAFKA-BINDER
Dominant language
Java
Stars
1.1k
Forks
646
Avg merge
2d 3h
Merged PRs (30d)
8

Description

@skomarica commented on Mon Dec 13 2021

Hi,

First of all, my apologies if this was already answered elsewhere; I reviewed the docs, SO Q&A and previous similar issues, but couldn't find the answer.

We use Kafka binder for our spring boot / cloud based services. The complete configuration is based on spring.cloud.stream.* properties and everything has been working as expected so far.

Now, I want to use the AdminClient to verify certain things on the cluster (e.g. list/describe topics). I tried using an autowired KafkaAdmin bean to provide the configuration properties, like:

        try (final AdminClient adminClient = AdminClient.create(kafkaAdmin.getConfigurationProperties())) {

, but these configuration properties don't seem to pick up any of the binder properties (e.g. spring.cloud.stream.kafka.binder.brokers, spring.cloud.stream.kafka.binder.configuration.*...). I also looked at the KafkaAdmin bean implementation and configuration, and it doesn't look like the class is supposed to do any kind of properties merging. If this is the case, it makes the auto-configured KafkaAdmin bean a bit pointless.

I see that the internal AdminClient used by KafkaTopicProvisioner gets initialised correctly, but there is a custom internal logic in the constructor of that class, normalising and merging the standard kafka properties with the kafka binder ones. Most of these classes and beans are internal / package private, and we can't easily use them.

The question is - is there a suggested way to create an AdminClient that will be correctly initialised, respecting all the spring.cloud.stream.kafka.binder.* properties?


@garyrussell commented on Mon Dec 13 2021

This is currently not supported; the auto-configured (by Boot) KafkaAdmin only uses the Boot properties.

Perhaps the KafkaTopicProvisioner could be modified to provide an API to retrieve the merged admin properties for each binding.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the KafkaTopicProvisioner initialization logic and the auto-configured KafkaAdmin behavior described in the issue. Trace how binder broker and configuration properties are merged, then define an exposed API or documented approach whose completion can be verified by creating an AdminClient that honors those binder properties.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kafka, spring-boot
Domain
backend, distributed-systems, stream-processing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.