Class DefaultPublisherFactory
java.lang.Object
com.google.cloud.spring.pubsub.support.DefaultPublisherFactory
- All Implemented Interfaces:
PublisherFactory
The default
PublisherFactory
implementation.
Creates Publisher
s for topics. Use CachingPublisherFactory
to cache them.
-
Constructor Summary
ConstructorDescriptionDefaultPublisherFactory
(GcpProjectIdProvider projectIdProvider) CreateDefaultPublisherFactory
instance based on the providedGcpProjectIdProvider
. -
Method Summary
Modifier and TypeMethodDescriptioncom.google.cloud.pubsub.v1.Publisher
createPublisher
(String topic) Creates aPublisher
for a given topic.void
setBatchingSettings
(com.google.api.gax.batching.BatchingSettings batchingSettings) Set the API call batching configuration.void
setChannelProvider
(com.google.api.gax.rpc.TransportChannelProvider channelProvider) Set the provider for the channel to be used by the publisher.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.void
setCustomizers
(List<PublisherCustomizer> customizers) Accepts a list ofPublisher.Builder
customizers.void
setEnableMessageOrdering
(Boolean enableMessageOrdering) Set whether message ordering should be enabled on the publisher.void
setEndpoint
(String endpoint) Set the publisher endpoint.void
setExecutorProvider
(com.google.api.gax.core.ExecutorProvider executorProvider) Set the provider for the executor that will be used by the publisher.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.void
setRetrySettings
(com.google.api.gax.retrying.RetrySettings retrySettings) Set the API call retry configuration.
-
Constructor Details
-
DefaultPublisherFactory
CreateDefaultPublisherFactory
instance based on the providedGcpProjectIdProvider
.The
GcpProjectIdProvider
must 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
-
setCustomizers
Accepts a list ofPublisher.Builder
customizers. The customizers are applied in the order provided, so the later customizers can override any settings provided by the earlier ones. -
createPublisher
Creates aPublisher
for a given topic. Configuration precedence:- modifications applied by the factory customizers
spring.cloud.gcp.pubsub.publisher
configuration options- client library defaults
- Specified by:
createPublisher
in interfacePublisherFactory
- Parameters:
topic
- destination topic- Returns:
- fully configured publisher
-