ServiceBusProcessor Class (Azure.Messaging.ServiceBus) - Azure for .NET Developers (original) (raw)
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
The ServiceBusProcessor is safe to cache and use for the lifetime of an application or until the ServiceBusClient that it was created by is disposed. Caching the processor is recommended when the application is processing messages regularly. The sender is responsible for ensuring efficient network, CPU, and memory use. Calling DisposeAsync() on the associated ServiceBusClient as the application is shutting down will ensure that network resources and other unmanaged objects used by the processor are properly cleaned up.
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 fully qualified Service Bus namespace that the receiver is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net.
Gets the maximum duration within which the lock will be renewed automatically. This value should be greater than the longest message lock duration; for example, the LockDuration Property.
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.
Performs the task needed to clean up resources used by the ServiceBusProcessor. Any in-flight message handlers will be awaited. Once all message handling has completed, the underlying links will be closed. After this point, the method will return. This is equivalent to calling DisposeAsync().
Performs the task needed to clean up resources used by the ServiceBusProcessor. Any in-flight message handlers will be awaited. Once all message handling has completed, the underlying links will be closed. After this point, the method will return. This is equivalent to calling CloseAsync(CancellationToken).
Invokes the error event handler when an error has occurred during processing. This method can be overridden to raise an event manually for testing purposes.
Invokes the process message event handler after a message has been received. This method can be overridden 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, anInvalidOperationException 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. Any in-flight message handlers will be awaited, and this method will not return until all in-flight message handlers have returned. To close the underlying receivers, CloseAsync(CancellationToken)should be called. If CloseAsync(CancellationToken) is called, the processor cannot be restarted. If you wish to resume processing at some point after calling this method, you can callStartProcessingAsync(CancellationToken).