public class DefaultSubscriberFactory extends Object implements SubscriberFactory
SubscriberFactory
implementation.Constructor and Description |
---|
DefaultSubscriberFactory(GcpProjectIdProvider projectIdProvider)
Deprecated.
Use the new
(GcpProjectIdProvider,PubSubConfiguration) instead |
DefaultSubscriberFactory(GcpProjectIdProvider projectIdProvider,
PubSubConfiguration pubSubConfiguration)
Default
DefaultSubscriberFactory constructor. |
Modifier and Type | Method and Description |
---|---|
com.google.pubsub.v1.PullRequest |
createPullRequest(String subscriptionName,
Integer maxMessages,
Boolean returnImmediately)
Create a
PullRequest for synchronously pulling a number of messages from
a Google Cloud Pub/Sub subscription. |
Subscriber |
createSubscriber(String subscriptionName,
MessageReceiver receiver)
Create a
Subscriber for the specified subscription name and wired it up to
asynchronously deliver messages to the provided MessageReceiver . |
SubscriberStub |
createSubscriberStub()
Create a
SubscriberStub that is needed to execute PullRequest s. |
SubscriberStub |
createSubscriberStub(String subscriptionName)
Create a
SubscriberStub that is needed to execute PullRequest s. |
com.google.api.gax.core.ExecutorProvider |
getExecutorProvider(String subscriptionName)
Creates
ExecutorProvider . |
com.google.api.gax.batching.FlowControlSettings |
getFlowControlSettings(String subscriptionName)
Fetches subscriber
FlowControlSettings . |
com.google.api.gax.core.ExecutorProvider |
getGlobalExecutorProvider() |
String |
getProjectId()
Method to get the project id.
|
com.google.api.gax.rpc.StatusCode.Code[] |
getRetryableCodes(String subscriptionName) |
com.google.api.gax.retrying.RetrySettings |
getRetrySettings(String subscriptionName)
Creates
RetrySettings , given subscriber retry properties. |
void |
setApiClock(com.google.api.core.ApiClock apiClock)
Set the clock to use for the retry logic in synchronous pulling.
|
void |
setChannelProvider(com.google.api.gax.rpc.TransportChannelProvider channelProvider)
Set the provider for the subscribers' transport channel.
|
void |
setCredentialsProvider(com.google.api.gax.core.CredentialsProvider credentialsProvider)
Set the provider for the GCP credentials to be used by the subscribers' API calls.
|
void |
setExecutorProvider(com.google.api.gax.core.ExecutorProvider executorProvider)
Set the provider for the subscribers' executor.
|
void |
setExecutorProviderMap(ConcurrentMap<String,com.google.api.gax.core.ExecutorProvider> executorProviderMap) |
void |
setFlowControlSettings(com.google.api.gax.batching.FlowControlSettings flowControlSettings)
Set the flow control for the subscribers, including the behaviour for when the flow limits
are hit.
|
void |
setFlowControlSettingsMap(ConcurrentMap<String,com.google.api.gax.batching.FlowControlSettings> flowControlSettingsMap) |
void |
setGlobalExecutorProvider(com.google.api.gax.core.ExecutorProvider executorProvider) |
void |
setGlobalFlowControlSettings(com.google.api.gax.batching.FlowControlSettings flowControlSettings) |
void |
setGlobalRetrySettings(com.google.api.gax.retrying.RetrySettings retrySettings) |
void |
setHeaderProvider(com.google.api.gax.rpc.HeaderProvider headerProvider)
Set the provider for the HTTP headers to be added to the subscribers' REST API calls.
|
void |
setHealthTrackerRegistry(HealthTrackerRegistry healthTrackerRegistry)
Set the health tracker chain for the generated subscriptions.
|
void |
setMaxAckExtensionPeriod(org.threeten.bp.Duration maxAckExtensionPeriod)
Set the maximum period the ack timeout is extended by.
|
void |
setParallelPullCount(Integer parallelPullCount)
Set the number of pull workers.
|
void |
setPullEndpoint(String pullEndpoint)
Set the endpoint for synchronous pulling messages.
|
void |
setRetryableCodes(com.google.api.gax.rpc.StatusCode.Code[] retryableCodes)
Set the retryable codes for subscriber pull settings.
|
void |
setRetrySettingsMap(ConcurrentMap<String,com.google.api.gax.retrying.RetrySettings> retrySettingsMap) |
void |
setSubscriberStubRetrySettings(com.google.api.gax.retrying.RetrySettings subscriberStubRetrySettings)
Set the retry settings for the generated subscriber stubs.
|
void |
setSystemExecutorProvider(com.google.api.gax.core.ExecutorProvider systemExecutorProvider)
Set the provider for the system executor, to poll and manage lease extensions.
|
@Deprecated public DefaultSubscriberFactory(GcpProjectIdProvider projectIdProvider)
(GcpProjectIdProvider,PubSubConfiguration)
insteadDefaultSubscriberFactory
constructor.projectIdProvider
- provides the default GCP project ID for selecting the
subscriptionspublic DefaultSubscriberFactory(GcpProjectIdProvider projectIdProvider, PubSubConfiguration pubSubConfiguration)
DefaultSubscriberFactory
constructor.projectIdProvider
- provides the default GCP project ID for selecting the subscriptionspubSubConfiguration
- contains the subscriber properties to configurepublic String getProjectId()
SubscriberFactory
getProjectId
in interface SubscriberFactory
public void setExecutorProvider(com.google.api.gax.core.ExecutorProvider executorProvider)
executorProvider
- the executor provider to setpublic void setChannelProvider(com.google.api.gax.rpc.TransportChannelProvider channelProvider)
channelProvider
- the channel provider to setpublic void setCredentialsProvider(com.google.api.gax.core.CredentialsProvider credentialsProvider)
credentialsProvider
- the credentials provider to setpublic void setHeaderProvider(com.google.api.gax.rpc.HeaderProvider headerProvider)
headerProvider
- the header provider to setpublic void setSystemExecutorProvider(com.google.api.gax.core.ExecutorProvider systemExecutorProvider)
systemExecutorProvider
- the system executor provider to setpublic void setFlowControlSettings(com.google.api.gax.batching.FlowControlSettings flowControlSettings)
flowControlSettings
- the flow control settings to setpublic void setMaxAckExtensionPeriod(org.threeten.bp.Duration maxAckExtensionPeriod)
maxAckExtensionPeriod
- the max ack extension period to setpublic void setParallelPullCount(Integer parallelPullCount)
parallelPullCount
- the parallel pull count to setpublic void setPullEndpoint(String pullEndpoint)
pullEndpoint
- the pull endpoint to setpublic void setApiClock(com.google.api.core.ApiClock apiClock)
apiClock
- the api clock to setpublic void setSubscriberStubRetrySettings(com.google.api.gax.retrying.RetrySettings subscriberStubRetrySettings)
subscriberStubRetrySettings
- parameters for retrying pull requests when they
fail, including jitter logic, timeout, and exponential backoffpublic void setRetryableCodes(com.google.api.gax.rpc.StatusCode.Code[] retryableCodes)
retryableCodes
- pull RPC response codes that should be retried.public void setHealthTrackerRegistry(HealthTrackerRegistry healthTrackerRegistry)
healthTrackerRegistry
- parameter for registering health trackers when creating subscriptionspublic Subscriber createSubscriber(String subscriptionName, MessageReceiver receiver)
SubscriberFactory
Subscriber
for the specified subscription name and wired it up to
asynchronously deliver messages to the provided MessageReceiver
.createSubscriber
in interface SubscriberFactory
subscriptionName
- the name of the subscriptionreceiver
- the callback for receiving messages asynchronouslySubscriber
that was created to bind the receiver to the subscriptionpublic com.google.pubsub.v1.PullRequest createPullRequest(String subscriptionName, Integer maxMessages, Boolean returnImmediately)
SubscriberFactory
PullRequest
for synchronously pulling a number of messages from
a Google Cloud Pub/Sub subscription.createPullRequest
in interface SubscriberFactory
subscriptionName
- the name of the subscriptionmaxMessages
- the maximum number of pulled messages; must be greater than zero.
If null is passed in, then up to Integer.MAX_VALUE messages will be requested.returnImmediately
- causes the pull request to return immediately even
if subscription doesn't contain enough messages to satisfy maxMessages
.
Setting this parameter to true
is not recommended as it may result in long delays in message delivery.SubscriberStub
public SubscriberStub createSubscriberStub()
SubscriberFactory
SubscriberStub
that is needed to execute PullRequest
s. This
method will only set global settings.createSubscriberStub
in interface SubscriberFactory
SubscriberStub
used for executing PullRequest
s.public SubscriberStub createSubscriberStub(String subscriptionName)
SubscriberFactory
SubscriberStub
that is needed to execute PullRequest
s.createSubscriberStub
in interface SubscriberFactory
subscriptionName
- the subscription nameSubscriberStub
used for executing PullRequest
spublic com.google.api.gax.core.ExecutorProvider getExecutorProvider(String subscriptionName)
ExecutorProvider
. If a custom executor provider is set then the
subscriber properties configured through the application.properties file will be
ignored.subscriptionName
- subscription namepublic com.google.api.gax.retrying.RetrySettings getRetrySettings(String subscriptionName)
RetrySettings
, given subscriber retry properties. Returns null if none
of the retry settings are set. Note that if retry settings are set using a
Spring-managed bean then subscription-specific settings in application.properties are
ignored.subscriptionName
- subscription namepublic com.google.api.gax.batching.FlowControlSettings getFlowControlSettings(String subscriptionName)
FlowControlSettings
. User-provided bean takes precedence
over properties from application.properties. Returns subscription-specific flow control
settings if present, otherwise, returns global subscriber settings.subscriptionName
- subscription namepublic com.google.api.gax.rpc.StatusCode.Code[] getRetryableCodes(String subscriptionName)
public void setExecutorProviderMap(ConcurrentMap<String,com.google.api.gax.core.ExecutorProvider> executorProviderMap)
public void setGlobalExecutorProvider(com.google.api.gax.core.ExecutorProvider executorProvider)
public com.google.api.gax.core.ExecutorProvider getGlobalExecutorProvider()
public void setFlowControlSettingsMap(ConcurrentMap<String,com.google.api.gax.batching.FlowControlSettings> flowControlSettingsMap)
public void setGlobalFlowControlSettings(com.google.api.gax.batching.FlowControlSettings flowControlSettings)
public void setRetrySettingsMap(ConcurrentMap<String,com.google.api.gax.retrying.RetrySettings> retrySettingsMap)
public void setGlobalRetrySettings(com.google.api.gax.retrying.RetrySettings retrySettings)
Copyright © 2021. All rights reserved.