Class DefaultPublisherFactory
java.lang.Object
com.google.cloud.spring.pubsub.support.DefaultPublisherFactory
- All Implemented Interfaces:
PublisherFactory
The default
PublisherFactory implementation.
Creates Publishers for topics. Use CachingPublisherFactory to cache them.
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultPublisherFactory(GcpProjectIdProvider projectIdProvider) CreateDefaultPublisherFactoryinstance based on the providedGcpProjectIdProvider. -
Method Summary
Modifier and TypeMethodDescriptioncom.google.cloud.pubsub.v1.PublishercreatePublisher(String topic) Creates aPublisherfor a given topic.voidsetBatchingSettings(com.google.api.gax.batching.BatchingSettings batchingSettings) Set the API call batching configuration.voidsetChannelProvider(com.google.api.gax.rpc.TransportChannelProvider channelProvider) Set the provider for the channel to be used by the publisher.voidsetCredentialsProvider(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.voidsetCustomizers(List<PublisherCustomizer> customizers) Accepts a list ofPublisher.Buildercustomizers.voidsetEnableMessageOrdering(Boolean enableMessageOrdering) Set whether message ordering should be enabled on the publisher.voidsetEndpoint(String endpoint) Set the publisher endpoint.voidsetExecutorProvider(com.google.api.gax.core.ExecutorProvider executorProvider) Set the provider for the executor that will be used by the publisher.voidsetHeaderProvider(com.google.api.gax.rpc.HeaderProvider headerProvider) Set the provider for the HTTP headers to be used in the Pub/Sub REST API requests.voidsetRetrySettings(com.google.api.gax.retrying.RetrySettings retrySettings) Set the API call retry configuration.voidsetUniverseDomain(String universeDomain)
-
Constructor Details
-
DefaultPublisherFactory
CreateDefaultPublisherFactoryinstance based on the providedGcpProjectIdProvider.The
GcpProjectIdProvidermust not be null, neither provide an emptyprojectId.- Parameters:
projectIdProvider- provides the default GCP project ID for selecting the topic
-
-
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
Set whether message ordering should be enabled on the publisher.- Parameters:
enableMessageOrdering- whether to enable message ordering
-
setEndpoint
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
-
setUniverseDomain
-
setCustomizers
Accepts a list ofPublisher.Buildercustomizers. The customizers are applied in the order provided, so the later customizers can override any settings provided by the earlier ones. -
createPublisher
Creates aPublisherfor a given topic. Configuration precedence:- modifications applied by the factory customizers
spring.cloud.gcp.pubsub.publisherconfiguration options- client library defaults
- Specified by:
createPublisherin interfacePublisherFactory- Parameters:
topic- destination topic- Returns:
- fully configured publisher
-