Class SubscriberClientImpl (2.3.0)

public sealed class SubscriberClientImpl : SubscriberClient

Implementation of SubscriberClient.

Inheritance

System.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.

clientsSystem.Collections.Generic.IEnumerable<SubscriberServiceApiClient>

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

settingsSubscriberClient.Settings

SubscriberClient.Settings for creating a SubscriberClient.

shutdownSystem.Func<System.Threading.Tasks.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 System.Threading.Tasks.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
handlerAsyncSystem.Func<PubsubMessage, System.Threading.CancellationToken, System.Threading.Tasks.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
System.Threading.Tasks.Task

A System.Threading.Tasks.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 System.Threading.Tasks.Task completes when all handled messages have been ACKnowledged. The returned System.Threading.Tasks.Task faults if there is an unrecoverable error with the underlying service. The returned System.Threading.Tasks.Task cancels if hardStopToken is cancelled.

Parameter
NameDescription
hardStopTokenSystem.Threading.CancellationToken

Cancel this System.Threading.CancellationToken to abort handlers and ACKnowledgement.

Returns
TypeDescription
System.Threading.Tasks.Task

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

Overrides