Class DefaultPublisherFactory

All Implemented Interfaces:

public class DefaultPublisherFactory extends Object implements PublisherFactory
The default PublisherFactory implementation.

Creates Publishers for topics. Use CachingPublisherFactory to cache them.

  • Constructor Details

  • Method Details

    • setExecutorProvider

      public void setExecutorProvider( executorProvider)
      Set the provider for the executor that will be used by the publisher. Useful to specify the number of threads to be used by each executor.
      executorProvider - the executor provider to set
    • setChannelProvider

      public void setChannelProvider( channelProvider)
      Set the provider for the channel to be used by the publisher. Useful to specify HTTP headers for the REST API calls.
      channelProvider - the channel provider to set
    • setCredentialsProvider

      public void setCredentialsProvider( credentialsProvider)
      Set the provider for the GCP credentials to be used by the publisher on every API calls it makes.
      credentialsProvider - the credentials provider to set
    • setHeaderProvider

      public void setHeaderProvider( headerProvider)
      Set the provider for the HTTP headers to be used in the Pub/Sub REST API requests.
      headerProvider - the header provider to set
    • setRetrySettings

      public void setRetrySettings( retrySettings)
      Set the API call retry configuration.
      retrySettings - the retry settings to set
    • setBatchingSettings

      public void setBatchingSettings( batchingSettings)
      Set the API call batching configuration.
      batchingSettings - the batching settings to set
    • setEnableMessageOrdering

      public void setEnableMessageOrdering(Boolean enableMessageOrdering)
      Set whether message ordering should be enabled on the publisher.
      enableMessageOrdering - whether to enable message ordering
    • setEndpoint

      public void setEndpoint(String endpoint)
      Set the publisher endpoint. Example: "". This is useful in conjunction with enabling message ordering because sending messages to the same region ensures they are received in order even when multiple publishers are used.
      endpoint - publisher endpoint
    • setCustomizers

      public void setCustomizers(List<PublisherCustomizer> customizers)
      Accepts a list of Publisher.Builder customizers. The customizers are applied in the order provided, so the later customizers can override any settings provided by the earlier ones.
    • createPublisher

      public createPublisher(String topic)
      Creates a Publisher for a given topic.

      Configuration precedence:
      1. modifications applied by the factory customizers
      2. configuration options
      3. client library defaults
      Specified by:
      createPublisher in interface PublisherFactory
      topic - destination topic
      fully configured publisher