Skip to content

v3.2.0 Feature Release

Compare
Choose a tag to compare
@Crim Crim released this 14 Nov 00:21
· 21 commits to master since this release
9ab7114

3.2.0 (11/13/2019)

  • ISSUE-38 Optionally allow for explicitly defining which ports kakfa brokers listen on.
Configuring explicit ports for broker(s)

Optionally if you require specific ports for the Kafka brokers to listen on, you can use the BrokerListener.onPorts(...) method when registering a listener.

Not calling the onPorts() method will have the broker(s) listen on randomly assigned ports (defaults to previous behavior).

    /**
     * This is an example of how to start a broker on an explicitly defined port of 1234.
     * The onPorts() can be called on any of the above listener types.
     */
    @RegisterExtension
    public static final SharedKafkaTestResource sharedKafkaTestResource = new SharedKafkaTestResource()
        .registerListener(new PlainListener().onPorts(1234));

    /**
     * If you are running a multi-broker cluster, you will need to pass a unique port for each 
     * broker in the cluster.
     * 
     * This example will have 2 brokers where:
     *   The first broker is listening on port 1234.
     *   The second broker is listening on port 4321.
     */
    @RegisterExtension
    public static final SharedKafkaTestResource sharedKafkaTestResource = new SharedKafkaTestResource()
        .withBrokers(2)
        .registerListener(new PlainListener().onPorts(1234, 4321));