Class ConnectionPolicy.Builder

java.lang.Object
org.apache.pulsar.client.api.v5.config.ConnectionPolicy.Builder
Enclosing class:
ConnectionPolicy

public static final class ConnectionPolicy.Builder extends Object
Builder for ConnectionPolicy.
  • Method Details

    • connectionTimeout

      public ConnectionPolicy.Builder connectionTimeout(Duration connectionTimeout)
      Timeout for establishing a TCP connection to the broker.
      Parameters:
      connectionTimeout - the maximum duration to wait for a TCP connection
      Returns:
      this builder
    • connectionsPerBroker

      public ConnectionPolicy.Builder connectionsPerBroker(int connectionsPerBroker)
      Maximum number of TCP connections per broker.
      Parameters:
      connectionsPerBroker - the number of connections to maintain per broker
      Returns:
      this builder
    • enableTcpNoDelay

      public ConnectionPolicy.Builder enableTcpNoDelay(boolean enableTcpNoDelay)
      Enable TCP no-delay (disable Nagle's algorithm). Default is true.
      Parameters:
      enableTcpNoDelay - true to enable TCP no-delay
      Returns:
      this builder
    • keepAliveInterval

      public ConnectionPolicy.Builder keepAliveInterval(Duration keepAliveInterval)
      Interval for sending keep-alive probes on idle connections.
      Parameters:
      keepAliveInterval - the duration between keep-alive probes
      Returns:
      this builder
    • connectionMaxIdleTime

      public ConnectionPolicy.Builder connectionMaxIdleTime(Duration connectionMaxIdleTime)
      Maximum idle time before a connection is closed.
      Parameters:
      connectionMaxIdleTime - the maximum idle duration
      Returns:
      this builder
    • ioThreads

      public ConnectionPolicy.Builder ioThreads(int ioThreads)
      Number of I/O threads for managing connections and reading data.
      Parameters:
      ioThreads - the number of I/O threads
      Returns:
      this builder
    • callbackThreads

      public ConnectionPolicy.Builder callbackThreads(int callbackThreads)
      Number of threads for message listener callbacks.
      Parameters:
      callbackThreads - the number of callback threads
      Returns:
      this builder
    • proxy

      public ConnectionPolicy.Builder proxy(String proxyServiceUrl, ProxyProtocol proxyProtocol)
      Connect through a proxy.
      Parameters:
      proxyServiceUrl - the URL of the proxy service
      proxyProtocol - the protocol to use when connecting through the proxy
      Returns:
      this builder
    • connectionBackoff

      public ConnectionPolicy.Builder connectionBackoff(BackoffPolicy connectionBackoff)
      Backoff strategy for broker reconnection attempts.
      Parameters:
      connectionBackoff - the backoff policy to use when reconnecting to the broker
      Returns:
      this builder
      See Also:
    • build

      public ConnectionPolicy build()
      Build the ConnectionPolicy.
      Returns:
      a new ConnectionPolicy instance