Skip to content

[Enhancement]: Allow user configuration of advertised.listeners property #10718

@kyguy

Description

@kyguy

Module

Kafka

Proposal

At this time, users cannot configure listener names or protocols of the advertised.listeners property through the TestContainers API. The KAFKA_ADVERTISED_LISTENERS env var configuration is not respected and gets overridden in the containerIsStarting() method [1] of the KafkaContainer class. Although we can have TestContainers add listeners to the advertised.listeners lists using the withListener(String listener, Supplier<String> advertisedListener) method, [2] it only allows creating listeners with the name of the format "TC-<listener_number>" with the PLAINTEXT protocol [3].

For standing up a TestContainers Kafka cluster for connections outside of the container network for protocols other than PLAINTEXT it would be really helpful if users had the ability to configure the advertised.listeners property. To make this possible, we could update the containerIsStarting() method [1] to add the listeners specified by the users in the KAFKA_ADVERTISED_LISTENERS env var to not be overwritten. Alternatively, we could enhance the withListener(String listener, Supplier<String> advertisedListener) method to allow users to specify listener names and protocols.

If this is of interest to the maintainers and community members I would be happy to contribute an enhancement myself. Let me know!

[1] https://github.com/testcontainers/testcontainers-java/blob/main/modules/kafka/src/main/java/org/testcontainers/kafka/KafkaContainer.java#L56-L75
[2] https://github.com/testcontainers/testcontainers-java/blob/main/modules/kafka/src/main/java/org/testcontainers/kafka/KafkaContainer.java#L134-L138
[3] #10035

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