All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.testcontainers.containers.PulsarContainer Maven / Gradle / Ivy

There is a newer version: 1.20.4
Show newest version
package org.testcontainers.containers;

import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.TestcontainersConfiguration;

/**
 * This container wraps Apache pulsar running in stanalone mode
 */
public class PulsarContainer extends GenericContainer {

    public static final int PULSAR_PORT = 6850;

    public PulsarContainer() {
        this("2.0.1-incubating");
    }

    public PulsarContainer(String pulsarVersion) {
        super(TestcontainersConfiguration.getInstance().getPulsarImage() + ":" + pulsarVersion);
        withExposedPorts(PULSAR_PORT);
        withCommand("/bin/bash", "-c", "" +
            "servicePort=6850 webServicePort=8280 webServicePortTls=8643 bin/apply-config-from-env.py conf/proxy.conf && " +
            "bin/pulsar standalone & " +
            "bin/pulsar proxy --zookeeper-servers localhost:2181 --global-zookeeper-servers localhost:2181"
        );

        waitingFor(Wait.forLogMessage(".*messaging service is ready.*\\s", 1));
    }

    public String getPulsarBrokerUrl() {
        return String.format("pulsar://%s:%s", this.getContainerIpAddress(), this.getFirstMappedPort());
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy