Class ServiceBusSessionMessageActions
Represents the set of actions that can be performed on a session and a message received from a Azure.Messaging.ServiceBus.ServiceBusReceivedMessage.
Inherited Members
Namespace: System.Dynamic.ExpandoObject
Assembly: Microsoft.Azure.WebJobs.Extensions.ServiceBus.dll
Syntax
public class ServiceBusSessionMessageActions : Microsoft.Azure.WebJobs.ServiceBus.ServiceBusMessageActions
Constructors
ServiceBusSessionMessageActions()
Initializes a new instance of the ServiceBusSessionMessageActions class for mocking use in testing.
Declaration
protected ServiceBusSessionMessageActions ();
Remarks
This constructor exists only to support mocking. When used, class state is not fully initialized, and
will not function correctly; virtual members are meant to be mocked.
Properties
SessionLockedUntil
Gets the System.DateTimeOffset that the receiver's session is locked until.
Declaration
public virtual DateTimeOffset SessionLockedUntil { get; }
Property Value
System.DateTimeOffset
|
Methods
GetSessionStateAsync(CancellationToken)
Gets the session state.
Declaration
[System.Diagnostics.DebuggerStepThrough]
public virtual System.Threading.Tasks.Task<BinaryData> GetSessionStateAsync (System.Threading.CancellationToken cancellationToken = null);
Parameters
System.Threading.CancellationToken
cancellationToken
An optional System.Threading.CancellationToken instance to signal the request to cancel the operation. |
Returns
System.Threading.Tasks.Task<System.BinaryData>
The session state as System.BinaryData. |
Exceptions
Azure.Messaging.ServiceBus.ServiceBusException
The lock for the session has expired. The Azure.Messaging.ServiceBus.ServiceBusException.Reason will be set to Azure.Messaging.ServiceBus.ServiceBusFailureReason.SessionLockLost in this case. |
ReleaseSession()
Releases the session that is being processed. No new receives will be initiated for the session before the
session is closed. Any already received messages will still be delivered to the user message handler, and in-flight message handlers
will be allowed to complete. Messages will still be completed automatically if Azure.Messaging.ServiceBus.ServiceBusSessionProcessorOptions.AutoCompleteMessages
is true
.
The session may end up being reopened for processing immediately after closing if there are messages remaining in the session (
This depends on what other session messages may be in the queue or subscription).
Declaration
public virtual void ReleaseSession ();
RenewSessionLockAsync(CancellationToken)
Renews the lock on the session specified by the Azure.Messaging.ServiceBus.ServiceBusSessionReceiver.SessionId. The lock will be renewed based on the setting specified on the entity.
Declaration
[System.Diagnostics.DebuggerStepThrough]
public virtual System.Threading.Tasks.Task RenewSessionLockAsync (System.Threading.CancellationToken cancellationToken = null);
Parameters
System.Threading.CancellationToken
cancellationToken
An optional System.Threading.CancellationToken instance to signal the request to cancel the operation. |
Returns
System.Threading.Tasks.Task
|
Remarks
When you accept a session, the session is locked for this receiver by the service for a duration as specified during the Queue/Subscription creation. If processing of the session requires longer than this duration, the session-lock needs to be renewed. For each renewal, it resets the time the session is locked by the LockDuration set on the Entity.
Renewal of session renews all the messages in the session as well. Each individual message need not be renewed.
Exceptions
Azure.Messaging.ServiceBus.ServiceBusException
The lock for the session has expired. The Azure.Messaging.ServiceBus.ServiceBusException.Reason will be set to Azure.Messaging.ServiceBus.ServiceBusFailureReason.SessionLockLost in this case. |
SetSessionStateAsync(BinaryData, CancellationToken)
Set a custom state on the session which can be later retrieved using Azure.Messaging.ServiceBus.ServiceBusSessionReceiver.GetSessionStateAsync(System.Threading.CancellationToken)
Declaration
[System.Diagnostics.DebuggerStepThrough]
public virtual System.Threading.Tasks.Task SetSessionStateAsync (BinaryData sessionState, System.Threading.CancellationToken cancellationToken = null);
Parameters
System.BinaryData
sessionState
A System.BinaryData of session state |
System.Threading.CancellationToken
cancellationToken
An optional System.Threading.CancellationToken instance to signal the request to cancel the operation. |
Returns
System.Threading.Tasks.Task
A task to be resolved on when the operation has completed. |
Remarks
This state is stored on Service Bus forever unless you set an empty state on it.
Exceptions
Azure.Messaging.ServiceBus.ServiceBusException
The lock for the session has expired. The Azure.Messaging.ServiceBus.ServiceBusException.Reason will be set to Azure.Messaging.ServiceBus.ServiceBusFailureReason.SessionLockLost in this case. |