Skip to content

There's no way to configure a port to listen on #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wr-pkazlenka opened this issue Nov 8, 2019 · 6 comments
Closed

There's no way to configure a port to listen on #38

wr-pkazlenka opened this issue Nov 8, 2019 · 6 comments

Comments

@wr-pkazlenka
Copy link

Hi,

Seems like possibility to set listener's port is removed in commit #28. Now it's being generated randomly.

Can you return 'port' broker property or add something like 'port.range' = "9000-9005" option so I can launch kafka on the port I want to.

Use case:
In tests first launch application with already configured kafka client, then start kafka server, passing to the kafka server configuration the port, where client is expected to connect to.

@Crim
Copy link
Collaborator

Crim commented Nov 9, 2019

That seems like a reasonable request.

With being able to start multiple brokers, each with the possibility of using multiple listeners, it gets a bit tricky on how to supply/configure ports for each broker when they all need to be bound to unique ports.

Do you have any suggestions/ideas on how you could see this working? Perhaps define a base port number for each listener, and then every broker offsets that port by its brokerId?

Example:

@ClassRule
    public static final SharedKafkaTestResource sharedKafkaTestResource = new SharedKafkaTestResource()
        // Start a cluster with 2 brokers.
        .withBrokers(2)
         // Register and configure SSL authentication on cluster.
        .registerListener(new SslListener().onPort(12345));
        

Where brokerId 0 listens on port 12345, and brokerId 1 listens on port 12346?

Thanks!

@wr-pkazlenka
Copy link
Author

May be it's better to use '.onPortRange(12345, 12348)?

If the port range is lesser than amount of brokers - raise WrongConfigurationException().
If the port range is bigger than amount of brokers - log warning "Number of ports configured is bigger than number of brokers - ports 12345 and 123456 will be used"
If the amounts are equal - go with each port provided.
If port range is not provided - run on random ports.

@Crim
Copy link
Collaborator

Crim commented Nov 13, 2019

@wr-pkazlenka checkout PullRequest #39 and let me know if this seems good?

Thanks!

@wr-pkazlenka
Copy link
Author

@Crim , thank you. The way it is implemented seems even better, than my initial suggestion.

@Crim
Copy link
Collaborator

Crim commented Nov 14, 2019

Great I'll merge this in and cut a release today.

Thanks for the suggestion and help!

@Crim
Copy link
Collaborator

Crim commented Nov 14, 2019

Released 3.2.0 to maven central. Let me know if you run into any issues.

Thanks!

@Crim Crim closed this as completed Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants