public static final class Subscriber.Builder extends Object
Subscribers
.Modifier and Type | Method and Description |
---|---|
Subscriber |
build() |
Subscriber.Builder |
setChannelProvider(TransportChannelProvider channelProvider)
ChannelProvider to use to create Channels, which must point at Cloud Pub/Sub
endpoint. |
Subscriber.Builder |
setCredentialsProvider(CredentialsProvider credentialsProvider)
CredentialsProvider to use to create Credentials to authenticate calls. |
Subscriber.Builder |
setExecutorProvider(ExecutorProvider executorProvider)
Gives the ability to set a custom executor.
|
Subscriber.Builder |
setFlowControlSettings(FlowControlSettings flowControlSettings)
Sets the flow control settings.
|
Subscriber.Builder |
setHeaderProvider(HeaderProvider headerProvider)
Sets the static header provider.
|
Subscriber.Builder |
setMaxAckExtensionPeriod(org.threeten.bp.Duration maxAckExtensionPeriod)
Set the maximum period a message ack deadline will be extended.
|
Subscriber.Builder |
setParallelPullCount(int parallelPullCount)
Sets the number of pullers used to pull messages from the subscription.
|
Subscriber.Builder |
setSystemExecutorProvider(ExecutorProvider executorProvider)
Gives the ability to set a custom executor for managing lease extensions.
|
public Subscriber.Builder setChannelProvider(TransportChannelProvider channelProvider)
ChannelProvider
to use to create Channels, which must point at Cloud Pub/Sub
endpoint.
For performance, this client benefits from having multiple channels open at once. Users
are encouraged to provide instances of ChannelProvider
that creates new channels
instead of returning pre-initialized ones.
@BetaApi public Subscriber.Builder setHeaderProvider(HeaderProvider headerProvider)
headerProvider
- the header providerpublic Subscriber.Builder setFlowControlSettings(FlowControlSettings flowControlSettings)
In the example below, the Subscriber
will make sure that
MessageReceiver
but not yet acked()
or nacked()
.
FlowControlSettings flowControlSettings =
FlowControlSettings.newBuilder()
.setMaxOutstandingElementCount(10_000L)
.setMaxOutstandingRequestBytes(1_000_000_000L)
.build();
Subscriber subscriber =
Subscriber.newBuilder(subscriptionName, receiver)
.setFlowControlSettings(flowControlSettings)
.build();
public Subscriber.Builder setMaxAckExtensionPeriod(org.threeten.bp.Duration maxAckExtensionPeriod)
It is recommended to set this value to a reasonable upper bound of the subscriber time to process any message. This maximum period avoids messages to be locked by a subscriber in cases when the ack reply is lost.
A zero duration effectively disables auto deadline extensions.
public Subscriber.Builder setExecutorProvider(ExecutorProvider executorProvider)
ExecutorProvider.getExecutor()
will be
called parallelPullCount
times.public Subscriber.Builder setCredentialsProvider(CredentialsProvider credentialsProvider)
CredentialsProvider
to use to create Credentials to authenticate calls.public Subscriber.Builder setSystemExecutorProvider(ExecutorProvider executorProvider)
Subscriber
instances.public Subscriber.Builder setParallelPullCount(int parallelPullCount)
public Subscriber build()
Copyright © 2019 Google LLC. All rights reserved.