Class AzureServiceBusReceiverBase<TBody, TConsumer>
- Namespace
- NuvTools.Notification.Messaging.Azure.ServiceBus
- Assembly
- NuvTools.Notification.Messaging.Azure.ServiceBus.dll
Abstract base class for Azure Service Bus receivers, containing shared message processing logic.
public abstract class AzureServiceBusReceiverBase<TBody, TConsumer> : BackgroundService, IHostedService, IDisposable where TBody : class where TConsumer : IMessageConsumer<TBody>
Type Parameters
TBodyTConsumer
- Inheritance
-
AzureServiceBusReceiverBase<TBody, TConsumer>
- Implements
- Derived
- Inherited Members
Constructors
AzureServiceBusReceiverBase(ILogger, IServiceProvider, MessagingSection, TokenCredential?)
protected AzureServiceBusReceiverBase(ILogger logger, IServiceProvider serviceProvider, MessagingSection messagingSection, TokenCredential? credential = null)
Parameters
loggerILoggerserviceProviderIServiceProvidermessagingSectionMessagingSectioncredentialTokenCredential
Properties
IsProcessing
protected abstract bool IsProcessing { get; }
Property Value
Methods
DisposeProcessorAsync()
protected abstract Task DisposeProcessorAsync()
Returns
ExecuteAsync(CancellationToken)
This method is called when the IHostedService starts. The implementation should return a task that represents the lifetime of the long running operation(s) being performed.
protected override Task ExecuteAsync(CancellationToken stoppingToken)
Parameters
stoppingTokenCancellationTokenTriggered when StopAsync(CancellationToken) is called.
Returns
Remarks
See Worker Services in .NET for implementation guidelines.
HandleError(ProcessErrorEventArgs)
protected Task HandleError(ProcessErrorEventArgs args)
Parameters
Returns
ProcessReceivedMessageAsync(ServiceBusReceivedMessage, string?, Func<CancellationToken, Task>, Func<CancellationToken, Task>, Func<string, string?, CancellationToken, Task>, CancellationToken)
Shared message processing logic for both regular and session receivers.
protected Task ProcessReceivedMessageAsync(ServiceBusReceivedMessage message, string? sessionId, Func<CancellationToken, Task> completeAsync, Func<CancellationToken, Task> abandonAsync, Func<string, string?, CancellationToken, Task> deadLetterAsync, CancellationToken cancellationToken)
Parameters
messageServiceBusReceivedMessagesessionIdstringcompleteAsyncFunc<CancellationToken, Task>abandonAsyncFunc<CancellationToken, Task>deadLetterAsyncFunc<string, string, CancellationToken, Task>cancellationTokenCancellationToken
Returns
RegisterHandlers()
protected abstract void RegisterHandlers()
RestartProcessorWithRetry(CancellationToken)
protected abstract Task RestartProcessorWithRetry(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
RestartWithRetry(Func<CancellationToken, Task>, CancellationToken)
protected Task RestartWithRetry(Func<CancellationToken, Task> startProcessingAsync, CancellationToken cancellationToken)
Parameters
startProcessingAsyncFunc<CancellationToken, Task>cancellationTokenCancellationToken
Returns
StartProcessorAsync(CancellationToken)
protected abstract Task StartProcessorAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
StopAsync(CancellationToken)
Triggered when the application host is performing a graceful shutdown.
public override Task StopAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenIndicates that the shutdown process should no longer be graceful.
Returns
StopProcessorAsync(CancellationToken)
protected abstract Task StopProcessorAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken