Interface PulsarClientSharedResources

All Superinterfaces:
AutoCloseable

public interface PulsarClientSharedResources extends AutoCloseable
Manages shared resources across multiple PulsarClient instances to optimize resource utilization. This interface provides access to common resources such as thread pools and DNS resolver/cache that can be shared between multiple PulsarClient instances. This allows creating a large number of PulsarClient instances in a single JVM without wasting resources. Sharing the DNS resolver and cache will help reduce the number of DNS lookups performed by the clients and improve latency and reduce load on the DNS servers.

Key features:

  • Thread pool sharing for various Pulsar operations (IO, timer, lookup, etc.)
  • Shared DNS resolver and cache
  • Resource lifecycle management

Usage example:


 // To share all possible resources across multiple PulsarClient instances
 PulsarClientSharedResources sharedResources = PulsarClientSharedResources.builder()
     .build();
 // Use these resources with multiple PulsarClient instances
 PulsarClient client1 = PulsarClient.builder().sharedResources(sharedResources).build();
 PulsarClient client2 = PulsarClient.builder().sharedResources(sharedResources).build();
 client1.close();
 client2.close();
 sharedResources.close();
 

The instance should be created using the PulsarClientSharedResourcesBuilder, which can be obtained via the builder() method.

See Also: