Class Subscriber.Builder
- Enclosing class:
- Subscriber
Subscribers
.-
Method Summary
Modifier and TypeMethodDescriptionbuild()
static com.google.api.gax.batching.FlowControlSettings
Returns the default FlowControlSettings used by the client if settings are not provided.setChannelProvider
(com.google.api.gax.rpc.TransportChannelProvider channelProvider) ChannelProvider
to use to create Channels, which must point at Cloud Pub/Sub endpoint.setCredentialsProvider
(com.google.api.gax.core.CredentialsProvider credentialsProvider) CredentialsProvider
to use to create Credentials to authenticate calls.setEndpoint
(String endpoint) Gives the ability to override the gRPC endpoint.setExecutorProvider
(com.google.api.gax.core.ExecutorProvider executorProvider) Gives the ability to set a custom executor.setFlowControlSettings
(com.google.api.gax.batching.FlowControlSettings flowControlSettings) Sets the flow control settings.setHeaderProvider
(com.google.api.gax.rpc.HeaderProvider headerProvider) Sets the static header provider.setMaxAckExtensionPeriod
(org.threeten.bp.Duration maxAckExtensionPeriod) Set the maximum period a message ack deadline will be extended.setMaxDurationPerAckExtension
(org.threeten.bp.Duration maxDurationPerAckExtension) Set the upper bound for a single mod ack extention period.setMinDurationPerAckExtension
(org.threeten.bp.Duration minDurationPerAckExtension) Set the lower bound for a single mod ack extention period.setParallelPullCount
(int parallelPullCount) Sets the number of StreamingPull streams to pull messages from the subscription.setSystemExecutorProvider
(com.google.api.gax.core.ExecutorProvider executorProvider) Gives the ability to set a custom executor for managing lease extensions.setUseLegacyFlowControl
(boolean value) Disables enforcing flow control settings at the Cloud PubSub server and uses the less accurate method of only enforcing flow control at the client side.
-
Method Details
-
setChannelProvider
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. -
setHeaderProvider
@BetaApi public Subscriber.Builder setHeaderProvider(com.google.api.gax.rpc.HeaderProvider headerProvider) Sets the static header provider. The header provider will be called during client construction only once. The headers returned by the provider will be cached and supplied as is for each request issued by the constructed client. Some reserved headers can be overridden (e.g. Content-Type) or merged with the default value (e.g. User-Agent) by the underlying transport layer.- Parameters:
headerProvider
- the header provider- Returns:
- the builder
-
setFlowControlSettings
public Subscriber.Builder setFlowControlSettings(com.google.api.gax.batching.FlowControlSettings flowControlSettings) Sets the flow control settings.In the example below, the
Subscriber
will make sure that- there are at most ten thousand outstanding messages, and
- the combined size of outstanding messages does not exceed 1GB.
MessageReceiver
but not yetacked()
ornacked()
.FlowControlSettings flowControlSettings = FlowControlSettings.newBuilder() .setMaxOutstandingElementCount(10_000L) .setMaxOutstandingRequestBytes(1_000_000_000L) .build(); Subscriber subscriber = Subscriber.newBuilder(subscriptionName, receiver) .setFlowControlSettings(flowControlSettings) .build();
-
setUseLegacyFlowControl
Disables enforcing flow control settings at the Cloud PubSub server and uses the less accurate method of only enforcing flow control at the client side. -
setMaxAckExtensionPeriod
Set the maximum period a message ack deadline will be extended. Defaults to one hour.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.
-
setMaxDurationPerAckExtension
public Subscriber.Builder setMaxDurationPerAckExtension(org.threeten.bp.Duration maxDurationPerAckExtension) Set the upper bound for a single mod ack extention period.The ack deadline will continue to be extended by up to this duration until MaxAckExtensionPeriod is reached. Setting MaxDurationPerAckExtension bounds the maximum amount of time before a mesage re-delivery in the event the Subscriber fails to extend the deadline.
MaxDurationPerAckExtension configuration can be disabled by specifying a zero duration.
-
setMinDurationPerAckExtension
public Subscriber.Builder setMinDurationPerAckExtension(org.threeten.bp.Duration minDurationPerAckExtension) Set the lower bound for a single mod ack extention period.The ack deadline will continue to be extended by up to this duration until MinAckExtensionPeriod is reached. Setting MinDurationPerAckExtension bounds the minimum amount of time before a mesage re-delivery in the event the Subscriber fails to extend the deadline.
MinDurationPerAckExtension configuration can be disabled by specifying a zero duration.
-
setExecutorProvider
public Subscriber.Builder setExecutorProvider(com.google.api.gax.core.ExecutorProvider executorProvider) Gives the ability to set a custom executor.ExecutorProvider.getExecutor()
will be calledparallelPullCount
times. -
setCredentialsProvider
public Subscriber.Builder setCredentialsProvider(com.google.api.gax.core.CredentialsProvider credentialsProvider) CredentialsProvider
to use to create Credentials to authenticate calls. -
setSystemExecutorProvider
public Subscriber.Builder setSystemExecutorProvider(com.google.api.gax.core.ExecutorProvider executorProvider) Gives the ability to set a custom executor for managing lease extensions. If none is provided a shared one will be used by allSubscriber
instances. -
setParallelPullCount
Sets the number of StreamingPull streams to pull messages from the subscription. Defaults to one. -
setEndpoint
Gives the ability to override the gRPC endpoint. -
getDefaultFlowControlSettings
public static com.google.api.gax.batching.FlowControlSettings getDefaultFlowControlSettings()Returns the default FlowControlSettings used by the client if settings are not provided. -
build
-