public class DefaultSubscriberFactory extends Object implements SubscriberFactory
SubscriberFactory
implementation.Constructor and Description |
---|
DefaultSubscriberFactory(GcpProjectIdProvider projectIdProvider)
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. |
String |
getProjectId()
Method to get the project id.
|
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 |
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 |
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 |
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 |
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.
|
public DefaultSubscriberFactory(GcpProjectIdProvider projectIdProvider)
DefaultSubscriberFactory
constructor.projectIdProvider
- provides the default GCP project ID for selecting the subscriptionspublic 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 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
SubscriberStub
public SubscriberStub createSubscriberStub()
SubscriberFactory
SubscriberStub
that is needed to execute PullRequest
s.createSubscriberStub
in interface SubscriberFactory
SubscriberStub
used for executing PullRequest
sCopyright © 2020 Pivotal Software, Inc.. All rights reserved.