Class SubscriberClientImpl (3.1.0)

public sealed class SubscriberClientImpl : SubscriberClient

Implementation of SubscriberClient.

Inheritance

Object > SubscriberClient > SubscriberClientImpl

Namespace

Google.Cloud.PubSub.V1

Assembly

Google.Cloud.PubSub.V1.dll

Constructors

SubscriberClientImpl(SubscriptionName, IEnumerable<SubscriberServiceApiClient>, SubscriberClient.Settings, Func<Task>)

public SubscriberClientImpl(SubscriptionName subscriptionName, IEnumerable<SubscriberServiceApiClient> clients, SubscriberClient.Settings settings, Func<Task> shutdown)

Instantiate a SubscriberClientImpl associated with the specified SubscriptionName.

Parameters
NameDescription
subscriptionNameSubscriptionName

The SubscriptionName to receive messages from.

clientsIEnumerable<SubscriberServiceApiClient>

The SubscriberServiceApiClients to use in a SubscriberClient. For high performance, these should all use distinct ChannelBases.

settingsSubscriberClient.Settings

SubscriberClient.Settings for creating a SubscriberClient.

shutdownFunc<Task>

Function to call on this SubscriberClientImpl shutdown.

Properties

SubscriptionName

public override SubscriptionName SubscriptionName { get; }

The associated SubscriptionName.

Property Value
TypeDescription
SubscriptionName
Overrides

Methods

StartAsync(Func<PubsubMessage, CancellationToken, Task<SubscriberClient.Reply>>)

public override Task StartAsync(Func<PubsubMessage, CancellationToken, Task<SubscriberClient.Reply>> handlerAsync)

Starts receiving messages. The returned Task completes when either StopAsync(CancellationToken) is called or if an unrecoverable fault occurs. See StopAsync(CancellationToken) for more details. This method cannot be called more than once per SubscriberClient instance.

Parameter
NameDescription
handlerAsyncFunc<PubsubMessage, CancellationToken, Task<SubscriberClient.Reply>>

The handler function that is passed all received messages. This function may be called on multiple threads concurrently. Return Ack from this function to ACKnowledge this message (implying it won't be received again); or return Nack to Not ACKnowledge this message (implying it will be received again). If this function throws any Exception, then it behaves as if it returned Nack.

Returns
TypeDescription
Task

A Task that completes when the subscriber is stopped, or if an unrecoverable error occurs.

Overrides

StopAsync(CancellationToken)

public override Task StopAsync(CancellationToken hardStopToken)

Stop this SubscriberClient. Cancelling hardStopToken aborts the clean stop process, and may leave some handled messages un-ACKnowledged. The returned Task completes when all handled messages have been ACKnowledged. The returned Task faults if there is an unrecoverable error with the underlying service. The returned Task cancels if hardStopToken is cancelled.

Parameter
NameDescription
hardStopTokenCancellationToken

Cancel this CancellationToken to abort handlers and ACKnowledgement.

Returns
TypeDescription
Task

A Task that completes when all handled messages have been ACKnowledged; faults on unrecoverable service errors; or cancels if hardStopToken is cancelled.

Overrides