Class DefaultPublisherFactory

java.lang.Object
com.google.cloud.spring.pubsub.support.DefaultPublisherFactory
All Implemented Interfaces:
PublisherFactory

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(com.google.api.gax.core.ExecutorProvider 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.
      Parameters:
      executorProvider - the executor provider to set
    • setChannelProvider

      public void setChannelProvider(com.google.api.gax.rpc.TransportChannelProvider channelProvider)
      Set the provider for the channel to be used by the publisher. Useful to specify HTTP headers for the REST API calls.
      Parameters:
      channelProvider - the channel provider to set
    • setCredentialsProvider

      public void setCredentialsProvider(com.google.api.gax.core.CredentialsProvider credentialsProvider)
      Set the provider for the GCP credentials to be used by the publisher on every API calls it makes.
      Parameters:
      credentialsProvider - the credentials provider to set
    • setHeaderProvider

      public void setHeaderProvider(com.google.api.gax.rpc.HeaderProvider headerProvider)
      Set the provider for the HTTP headers to be used in the Pub/Sub REST API requests.
      Parameters:
      headerProvider - the header provider to set
    • setRetrySettings

      public void setRetrySettings(com.google.api.gax.retrying.RetrySettings retrySettings)
      Set the API call retry configuration.
      Parameters:
      retrySettings - the retry settings to set
    • setBatchingSettings

      public void setBatchingSettings(com.google.api.gax.batching.BatchingSettings batchingSettings)
      Set the API call batching configuration.
      Parameters:
      batchingSettings - the batching settings to set
    • setEnableMessageOrdering

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

      public void setEndpoint(String endpoint)
      Set the publisher endpoint. Example: "us-east1-pubsub.googleapis.com:443". 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.
      Parameters:
      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 com.google.cloud.pubsub.v1.Publisher createPublisher(String topic)
      Creates a Publisher for a given topic.

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