Skip to main content
Version: 4.0.x

Initialize a Java client

You can instantiate a PulsarClient object using just a URL for the target Pulsar cluster like this:

PulsarClient client = PulsarClient.builder()
.serviceUrl("pulsar://localhost:6650")
.build();

If you have multiple brokers, you can initiate a PulsarClient like this:

PulsarClient client = PulsarClient.builder()
.serviceUrl("pulsar://localhost:6650,localhost:6651,localhost:6652")
.build();
note

If you run a cluster in standalone mode, the broker is available at the pulsar://localhost:6650 URL by default.

For detailed client configurations, see the reference doc.