Skip to content

Autowired does not support EmbeddedKafkaZKBroker #3585

@TheMagicNacho

Description

@TheMagicNacho

In what version(s) of Spring for Apache Kafka are you seeing this issue?
Spring-Kafka: 3.2.4
Spring-Boot: 3.3.4

Describe the bug
Because of the upgrade from older Spring-Kafka versions, we need to use EmbeddedKafkaZKBroker.

In doing so, @Autowired does not support EmbeddedKafkaZKBroker and yields the error: "Cannot find symbol" for getBrokerAddress().

The current fix is to instantiate EmbeddedKafkaZKBroker object.
This fix doesn't truly work. It allows the app to compile but it fails at runtime.

To Reproduce
Try to autowire the broker.

@Autowired
private EmbeddedKafkaZKBroker kafkaBroker;

// Remainder of code

Error will say:

[ERROR] <path> cannot find symbol
[ERROR] symbol: getBrokerAdress(int)

Expected behavior

Upgrading from EmbededKafkaBroker to EmbeddedKafkaZKBroker should be a drop in replacement.

Sample

This is what the current work around looks like

private EmbeddedKafkaZKBroker kafkaBroker = new EmbeddedKafkaZKBroker(10);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions