Bus Session Processor Class
The ServiceBusSessionProcessor provides an abstraction around a set of ServiceBusSessionReceiver that allows using an event based model for processing received ServiceBusReceivedMessage. It is constructed by calling CreateSessionProcessor(String, ServiceBusSessionProcessorOptions). The message handler is specified with the ProcessMessageAsync property. The error handler is specified with the ProcessErrorAsync property. To start processing after the handlers have been specified, call StartProcessingAsync(CancellationToken).
public class ServiceBusSessionProcessor : IAsyncDisposable
type ServiceBusSessionProcessor = class interface IAsyncDisposable
Public Class ServiceBusSessionProcessor Implements IAsyncDisposable
Initializes a new instance of the ServiceBusSessionProcessor class for mocking.
Gets a value that indicates whether the processor should automatically complete messages after the message handler has completed processing. If the message handler triggers an exception, the message will not be automatically completed.
Gets the path of the Service Bus entity that the processor is connected to, specific to the Service Bus namespace that contains it.
Gets the fully qualified Service Bus namespace that the receiver is associated with. This is likely
to be similar to
The ServiceBusProcessor that the session processor delegates to. This can be overriden for testing purposes.
Indicates whether or not this ServiceBusSessionProcessor has been closed.
Gets whether or not this processor is currently processing messages.
Gets the maximum duration within which the session lock will be renewed automatically.
Gets the maximum number of calls to the callback the processor will initiate per session. Thus the total number of callbacks will be equal to MaxConcurrentSessions * MaxConcurrentCallsPerSession. The default value is 1.
Gets the maximum number of sessions that will be processed concurrently by the processor. The default value is 8.
Gets the number of messages that will be eagerly requested from Queues or Subscriptions during processing. This is intended to help maximize throughput by allowing the processor to receive from a local cache rather than waiting on a service request.
Gets the ReceiveMode used to specify how messages are received. Defaults to PeekLock mode.
Gets the maximum amount of time to wait for a message to be received for the currently active session. After this time has elapsed, the processor will close the session and attempt to process another session. If not specified, the TryTimeout will be used.
Performs the task needed to clean up resources used by the ServiceBusSessionProcessor.
Performs the task needed to clean up resources used by the ServiceBusSessionProcessor. This is equivalent to calling CloseAsync(CancellationToken) with the default Azure.Messaging.ServiceBus.LinkCloseMode.
Invokes the error event handler when an error has occured during processing. This method can be overriden to raise an event manually for testing purposes.
Invokes the process message event handler after a message has been received. This method can be overriden to raise an event manually for testing purposes.
Invokes the session close event handler when a session is about to be closed for processing. This method can be overriden to raise an event manually for testing purposes.
Invokes the session open event handler when a new session is about to be processed. This method can be overriden to raise an event manually for testing purposes.
Signals the processor to begin processing messages. Should this method be called while the processor is already running, an InvalidOperationException is thrown.
Signals the processor to stop processing messaging. Should this method be called while the processor is not running, no action is taken. This method will not close the underlying receivers, but will cause the receivers to stop receiving. To close the underlying receivers, CloseAsync(CancellationToken) should be called.
The handler responsible for processing unhandled exceptions thrown while this processor is running. Implementation is mandatory.
The handler responsible for processing messages received from the Queue or Subscription. Implementation is mandatory.
Optional handler that can be set to be notified when a session is about to be closed for processing. This means that the most recent ReceiveMessageAsync(Nullable<TimeSpan>, CancellationToken) call timed out, so there are currently no messages available to be received for the session.
Optional handler that can be set to be notified when a new session is about to be processed.