public static final class Subscriber.Builder extends Object
Subscribers
.Modifier and Type | Method and Description |
---|---|
Subscriber |
build() |
Subscriber.Builder |
setChannelProvider(com.google.api.gax.rpc.TransportChannelProvider channelProvider)
ChannelProvider to use to create Channels, which must point at Cloud Pub/Sub
endpoint. |
Subscriber.Builder |
setCredentialsProvider(com.google.api.gax.core.CredentialsProvider credentialsProvider)
CredentialsProvider to use to create Credentials to authenticate calls. |
Subscriber.Builder |
setEndpoint(String endpoint)
Gives the ability to override the gRPC endpoint.
|
Subscriber.Builder |
setExecutorProvider(com.google.api.gax.core.ExecutorProvider executorProvider)
Gives the ability to set a custom executor.
|
Subscriber.Builder |
setFlowControlSettings(com.google.api.gax.batching.FlowControlSettings flowControlSettings)
Sets the flow control settings.
|
Subscriber.Builder |
setHeaderProvider(com.google.api.gax.rpc.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(com.google.api.gax.core.ExecutorProvider executorProvider)
Gives the ability to set a custom executor for managing lease extensions.
|
public Subscriber.Builder setChannelProvider(com.google.api.gax.rpc.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(com.google.api.gax.rpc.HeaderProvider headerProvider)
headerProvider
- the header providerpublic Subscriber.Builder setFlowControlSettings(com.google.api.gax.batching.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(com.google.api.gax.core.ExecutorProvider executorProvider)
ExecutorProvider.getExecutor()
will be
called parallelPullCount
times.public Subscriber.Builder setCredentialsProvider(com.google.api.gax.core.CredentialsProvider credentialsProvider)
CredentialsProvider
to use to create Credentials to authenticate calls.public Subscriber.Builder setSystemExecutorProvider(com.google.api.gax.core.ExecutorProvider executorProvider)
Subscriber
instances.public Subscriber.Builder setParallelPullCount(int parallelPullCount)
public Subscriber.Builder setEndpoint(String endpoint)
public Subscriber build()
Copyright © 2019 Google LLC. All rights reserved.