Skip to main content

Work with clients

After setting up your client library and creating a client object, you can explore more to start working with your client.

Create a client with multiple advertised listeners

To ensure clients in both internal and external networks can connect to a Pulsar cluster, Pulsar introduces advertisedListeners.

The following example creates a Python client using multiple advertised listeners:

PulsarClient client = PulsarClient.builder()
.serviceUrl("pulsar://xxxx:6650")
.listenerName("external")
.build();

Set memory limits

You can uses memory limits param to control client overall memory usage, the producers and consumers under this client will compete for the memory assigned. See PIP 74: Pulsar client memory limits

PulsarClient client = PulsarClient.builder()
.serviceUrl("pulsar://xxxx:6650")
.memoryLimit(64, SizeUnit.MEGA_BYTES)
.build();