Class Publisher.Builder (1.143.0) 
  
  
  
   
  
    
  
  
    
    
    
    
  Version latestkeyboard_arrow_down  
  
 
    
    
    
    
      
  
  
  
    
public   static   final   class  Publisher . Builder  
  
  
  
  Static Methods
   
  getDefaultBatchingSettings() 
  
    
public   static   BatchingSettings   getDefaultBatchingSettings ()  
  Returns the default BatchingSettings used by the client if settings are not provided.
Methods
   
  build() 
  
  
  
  setBatchingSettings(BatchingSettings batchingSettings) 
  
    
public   Publisher . Builder   setBatchingSettings ( BatchingSettings   batchingSettings )  
  
  
  setChannelProvider(TransportChannelProvider channelProvider) 
  
    
public   Publisher . Builder   setChannelProvider ( TransportChannelProvider   channelProvider )  
  ChannelProvider to use to create Channels, which must point at Cloud Pub/Sub
 endpoint.
 
For performance, this client benefits from having multiple underlying connections. See
 com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.Builder#setPoolSize(int) .
setCompressionBytesThreshold(long compressionBytesThreshold) 
  
    
public   Publisher . Builder   setCompressionBytesThreshold ( long   compressionBytesThreshold )  
  Sets the threshold (in bytes) above which messages are compressed for transport. Only takes
 effect if setEnableCompression(true) is also called."
    
      
        Parameter  
      
        Name Description  
      
        compressionBytesThresholdlong  
     
  
  
  setCredentialsProvider(CredentialsProvider credentialsProvider) 
  
    
public   Publisher . Builder   setCredentialsProvider ( CredentialsProvider   credentialsProvider )  
  CredentialsProvider to use to create Credentials to authenticate calls.
setEnableCompression(boolean enableCompression) 
  
    
public   Publisher . Builder   setEnableCompression ( boolean   enableCompression )  
  Gives the ability to enable transport compression.
    
      
        Parameter  
      
        Name Description  
      
        enableCompressionboolean  
     
  
  
  setEnableMessageOrdering(boolean enableMessageOrdering) 
  
    
public   Publisher . Builder   setEnableMessageOrdering ( boolean   enableMessageOrdering )  
  Sets the message ordering option.
    
      
        Parameter  
      
        Name Description  
      
        enableMessageOrderingboolean  
     
  
  
  setEnableOpenTelemetryTracing(boolean enableOpenTelemetryTracing) 
  
    
public   Publisher . Builder   setEnableOpenTelemetryTracing ( boolean   enableOpenTelemetryTracing )  
  Gives the ability to enable Open Telemetry Tracing
    
      
        Parameter  
      
        Name Description  
      
        enableOpenTelemetryTracingboolean  
     
  
  
  setEndpoint(String endpoint) 
  
    
public   Publisher . Builder   setEndpoint ( String   endpoint )  
  Gives the ability to override the gRPC endpoint.
    
      
        Parameter  
      
        Name Description  
      
        endpointString  
     
  
  
  setExecutorProvider(ExecutorProvider executorProvider) 
  
    
public   Publisher . Builder   setExecutorProvider ( ExecutorProvider   executorProvider )  
  Gives the ability to set a custom executor to be used by the library.
    
public   Publisher . Builder   setHeaderProvider ( HeaderProvider   headerProvider )  
  
Beta 
This feature is covered by the Pre-GA Offerings Terms  of the Terms of Service. Pre-GA libraries might have limited support, and changes to pre-GA libraries might not be compatible with other pre-GA versions. For more information, see the launch stage descriptions.
 
Sets the static header provider. The header provider will be called during client
 construction only once. The headers returned by the provider will be cached and supplied as
 is for each request issued by the constructed client. Some reserved headers can be overridden
 (e.g. Content-Type) or merged with the default value (e.g. User-Agent) by the underlying
 transport layer.
    
      
        Parameter  
      
        Name Description  
      
        headerProviderHeaderProvider the header provider
 
     
  
  
  setOpenTelemetry(OpenTelemetry openTelemetry) 
  
    
public   Publisher . Builder   setOpenTelemetry ( OpenTelemetry   openTelemetry )  
  Sets the instance of OpenTelemetry for the Publisher class.
    
      
        Parameter  
      
        Name Description  
      
        openTelemetryio.opentelemetry.api.OpenTelemetry  
     
  
  
  setRetrySettings(RetrySettings retrySettings) 
  
    
public   Publisher . Builder   setRetrySettings ( RetrySettings   retrySettings )  
  Configures the Publisher's retry parameters.
    
public   Publisher . Builder   setTransform ( ApiFunction<PubsubMessage , PubsubMessage >  messageTransform )  
  
Beta 
This feature is covered by the Pre-GA Offerings Terms  of the Terms of Service. Pre-GA libraries might have limited support, and changes to pre-GA libraries might not be compatible with other pre-GA versions. For more information, see the launch stage descriptions.
 
Gives the ability to set an ApiFunction  that will transform the PubsubMessage 
 before it is sent
setUniverseDomain(String universeDomain) 
  
    
public   Publisher . Builder   setUniverseDomain ( String   universeDomain )  
  Gives the ability to override the universe domain.
    
      
        Parameter  
      
        Name Description  
      
        universeDomainString  
     
  
  
 
     
    
  
  
  
     
  
    
    
      
       
    
    
  
  
 
  Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
  Last updated 2025-10-29 UTC.
 
 
  
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-10-29 UTC."],[],[]]