public sealed class SubscriberClientImpl : SubscriberClient, IAsyncDisposableReference documentation and code samples for the Cloud Pub/Sub v1 API class SubscriberClientImpl.
Implementation of SubscriberClient.
Implements
IAsyncDisposableNamespace
Google.Cloud.PubSub.V1Assembly
Google.Cloud.PubSub.V1.dll
Constructors
SubscriberClientImpl(SubscriptionName, IEnumerable<SubscriberServiceApiClient>, 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 | |
|---|---|
| Name | Description |
subscriptionName |
SubscriptionNameThe SubscriptionName to receive messages from. |
clients |
IEnumerableSubscriberServiceApiClientThe SubscriberServiceApiClients to use in a SubscriberClient. For high performance, these should all use distinct ChannelBases. |
settings |
SubscriberClientSettingsSubscriberClient.Settings for creating a SubscriberClient. |
shutdown |
FuncTaskFunction to call on this SubscriberClientImpl shutdown. |
Properties
SubscriptionName
public override SubscriptionName SubscriptionName { get; }The associated SubscriptionName.
| Property Value | |
|---|---|
| Type | Description |
SubscriptionName |
|
Methods
DisposeAsync()
public override ValueTask DisposeAsync()Disposes this SubscriberClient asynchronously.
| Returns | |
|---|---|
| Type | Description |
ValueTask |
|
This method asynchronously waits for the time interval as specified in the DisposeTimeout for the SubscriberClient to acknowledge the handled messages. If the clean shutdown is not complete after this time, it is aborted; this may leave some handled messages un-acknowledged. The time interval can be customized by setting the DisposeTimeout.
StartAsync(SubscriptionHandler)
public override Task StartAsync(SubscriptionHandler handler)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 | |
|---|---|
| Name | Description |
handler |
SubscriptionHandlerThe handler that is passed all received messages and acknowledgement results. |
| Returns | |
|---|---|
| Type | Description |
Task |
A Task that completes when the subscriber is stopped, or if an unrecoverable error occurs. |
StartAsync(Func<PubsubMessage, CancellationToken, Task<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 | |
|---|---|
| Name | Description |
handlerAsync |
FuncPubsubMessageCancellationTokenTaskSubscriberClientReplyThe 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 | |
|---|---|
| Type | Description |
Task |
A Task that completes when the subscriber is stopped, or if an unrecoverable error occurs. |
StopAsync(ShutdownOptions, CancellationToken)
public override Task StopAsync(SubscriberClient.ShutdownOptions shutdownOptions, CancellationToken cancellationToken = default)Stops this SubscriberClient.
The returned Task completes when the shutdown is finished according to the
shutdownOptions or when the cancellationToken is cancelled.
The returned Task faults if an unrecoverable error occurs in the underlying service.
The returned Task cancels if cancellationToken is cancelled.
| Parameters | |
|---|---|
| Name | Description |
shutdownOptions |
SubscriberClientShutdownOptionsThe SubscriberClient.ShutdownOptions to use for shutdown. |
cancellationToken |
CancellationTokenCancel this CancellationToken to immediately abort handlers and acknowledgement. |
| Returns | |
|---|---|
| Type | Description |
Task |
A Task that completes when the subscriber is stopped, or if an unrecoverable error occurs. |