Class ServiceBusMessageActions
Represents the set of message actions that can be performed on a Azure.Messaging.ServiceBus.ServiceBusReceivedMessage.
Inheritance
Namespace: System.Dynamic.ExpandoObject
Assembly: Microsoft.Azure.WebJobs.Extensions.ServiceBus.dll
Syntax
public class ServiceBusMessageActions
Constructors
ServiceBusMessageActions()
Initializes a new instance of the ServiceBusMessageActions class for mocking use in testing.
Declaration
protected ServiceBusMessageActions ();
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.
Methods
AbandonMessageAsync(ServiceBusReceivedMessage, IDictionary<String,Object>, CancellationToken)
Abandons a Azure.Messaging.ServiceBus.ServiceBusReceivedMessage.This will make the message available again for immediate processing as the lock on the message held by the receiver will be released.
Declaration
[System.Diagnostics.DebuggerStepThrough]
public virtual System.Threading.Tasks.Task AbandonMessageAsync (Azure.Messaging.ServiceBus.ServiceBusReceivedMessage message, System.Collections.Generic.IDictionary<string,object> propertiesToModify = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
Azure.Messaging.ServiceBus.ServiceBusReceivedMessage
message
The Azure.Messaging.ServiceBus.ServiceBusReceivedMessage to abandon. |
System.Collections.Generic.IDictionary<System.String,System.Object>
propertiesToModify
The properties of the message to modify while abandoning the message. |
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
Abandoning a message will increase the delivery count on the message. This operation can only be performed on messages that were received by this receiver when Azure.Messaging.ServiceBus.ServiceBusReceiver.ReceiveMode is set to Azure.Messaging.ServiceBus.ServiceBusReceiveMode.PeekLock.
Exceptions
Azure.Messaging.ServiceBus.ServiceBusException
|
CompleteMessageAsync(ServiceBusReceivedMessage, CancellationToken)
Completes a Azure.Messaging.ServiceBus.ServiceBusReceivedMessage. This will delete the message from the service.
Declaration
[System.Diagnostics.DebuggerStepThrough]
public virtual System.Threading.Tasks.Task CompleteMessageAsync (Azure.Messaging.ServiceBus.ServiceBusReceivedMessage message, System.Threading.CancellationToken cancellationToken = null);
Parameters
Azure.Messaging.ServiceBus.ServiceBusReceivedMessage
message
The message to complete. |
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 operation can only be performed on a message that was received by this receiver when Azure.Messaging.ServiceBus.ServiceBusReceiver.ReceiveMode is set to Azure.Messaging.ServiceBus.ServiceBusReceiveMode.PeekLock.
Exceptions
Azure.Messaging.ServiceBus.ServiceBusException
|
DeadLetterMessageAsync(ServiceBusReceivedMessage, IDictionary<String,Object>, CancellationToken)
Moves a message to the dead-letter subqueue.
Declaration
[System.Diagnostics.DebuggerStepThrough]
public virtual System.Threading.Tasks.Task DeadLetterMessageAsync (Azure.Messaging.ServiceBus.ServiceBusReceivedMessage message, System.Collections.Generic.IDictionary<string,object> propertiesToModify = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
Azure.Messaging.ServiceBus.ServiceBusReceivedMessage
message
The Azure.Messaging.ServiceBus.ServiceBusReceivedMessage to dead-letter. |
System.Collections.Generic.IDictionary<System.String,System.Object>
propertiesToModify
The properties of the message to modify while moving to subqueue. |
System.Threading.CancellationToken
cancellationToken
An optional System.Threading.CancellationToken instance to signal the request to cancel the operation. |
Returns
System.Threading.Tasks.Task
|
Remarks
In order to receive a message from the dead-letter queue or transfer dead-letter queue, set the Azure.Messaging.ServiceBus.ServiceBusReceiverOptions.SubQueue property to Azure.Messaging.ServiceBus.SubQueue.DeadLetter or Azure.Messaging.ServiceBus.SubQueue.TransferDeadLetter when calling Azure.Messaging.ServiceBus.ServiceBusClient.CreateReceiver(System.String,Azure.Messaging.ServiceBus.ServiceBusReceiverOptions) or Azure.Messaging.ServiceBus.ServiceBusClient.CreateReceiver(System.String,System.String,Azure.Messaging.ServiceBus.ServiceBusReceiverOptions). This operation can only be performed when Azure.Messaging.ServiceBus.ServiceBusReceiver.ReceiveMode is set to Azure.Messaging.ServiceBus.ServiceBusReceiveMode.PeekLock.
Exceptions
Azure.Messaging.ServiceBus.ServiceBusException
|
DeadLetterMessageAsync(ServiceBusReceivedMessage, String, String, CancellationToken)
Moves a message to the dead-letter subqueue.
Declaration
[System.Diagnostics.DebuggerStepThrough]
public virtual System.Threading.Tasks.Task DeadLetterMessageAsync (Azure.Messaging.ServiceBus.ServiceBusReceivedMessage message, string deadLetterReason, string deadLetterErrorDescription = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
Azure.Messaging.ServiceBus.ServiceBusReceivedMessage
message
The Azure.Messaging.ServiceBus.ServiceBusReceivedMessage to dead-letter. |
System.String
deadLetterReason
The reason for dead-lettering the message. |
System.String
deadLetterErrorDescription
The error description for dead-lettering the message. |
System.Threading.CancellationToken
cancellationToken
An optional System.Threading.CancellationToken instance to signal the request to cancel the operation. |
Returns
System.Threading.Tasks.Task
|
Remarks
In order to receive a message from the dead-letter queue or transfer dead-letter queue, set the Azure.Messaging.ServiceBus.ServiceBusReceiverOptions.SubQueue property to Azure.Messaging.ServiceBus.SubQueue.DeadLetter or Azure.Messaging.ServiceBus.SubQueue.TransferDeadLetter when calling Azure.Messaging.ServiceBus.ServiceBusClient.CreateReceiver(System.String,Azure.Messaging.ServiceBus.ServiceBusReceiverOptions) or Azure.Messaging.ServiceBus.ServiceBusClient.CreateReceiver(System.String,System.String,Azure.Messaging.ServiceBus.ServiceBusReceiverOptions). This operation can only be performed when Azure.Messaging.ServiceBus.ServiceBusReceiver.ReceiveMode is set to Azure.Messaging.ServiceBus.ServiceBusReceiveMode.PeekLock.
Exceptions
Azure.Messaging.ServiceBus.ServiceBusException
|
System.ArgumentOutOfRangeException
|
DeadLetterMessageAsync(ServiceBusReceivedMessage, Dictionary<String,Object>, String, String, CancellationToken)
Moves a message to the dead-letter subqueue.
Declaration
[System.Diagnostics.DebuggerStepThrough]
public virtual System.Threading.Tasks.Task DeadLetterMessageAsync (Azure.Messaging.ServiceBus.ServiceBusReceivedMessage message, System.Collections.Generic.Dictionary<string,object> propertiesToModify, string deadLetterReason, string deadLetterErrorDescription = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
Azure.Messaging.ServiceBus.ServiceBusReceivedMessage
message
The Azure.Messaging.ServiceBus.ServiceBusReceivedMessage to dead-letter. |
System.Collections.Generic.Dictionary<System.String,System.Object>
propertiesToModify
The properties of the message to modify while moving to subqueue. |
System.String
deadLetterReason
The reason for dead-lettering the message. |
System.String
deadLetterErrorDescription
The error description for dead-lettering the message. |
System.Threading.CancellationToken
cancellationToken
An optional System.Threading.CancellationToken instance to signal the request to cancel the operation. |
Returns
System.Threading.Tasks.Task
|
Remarks
In order to receive a message from the dead-letter queue or transfer dead-letter queue, set the Azure.Messaging.ServiceBus.ServiceBusReceiverOptions.SubQueue property to Azure.Messaging.ServiceBus.SubQueue.DeadLetter or Azure.Messaging.ServiceBus.SubQueue.TransferDeadLetter when calling Azure.Messaging.ServiceBus.ServiceBusClient.CreateReceiver(System.String,Azure.Messaging.ServiceBus.ServiceBusReceiverOptions) or Azure.Messaging.ServiceBus.ServiceBusClient.CreateReceiver(System.String,System.String,Azure.Messaging.ServiceBus.ServiceBusReceiverOptions). This operation can only be performed when Azure.Messaging.ServiceBus.ServiceBusReceiver.ReceiveMode is set to Azure.Messaging.ServiceBus.ServiceBusReceiveMode.PeekLock. The dead letter reason and error description can only be specified either through the method parameters or hard coded using this properties.
Exceptions
Azure.Messaging.ServiceBus.ServiceBusException
|
System.InvalidOperationException
|
System.ArgumentOutOfRangeException
|
DeferMessageAsync(ServiceBusReceivedMessage, IDictionary<String,Object>, CancellationToken)
Indicates that the receiver wants to defer the processing for the message.
Declaration
[System.Diagnostics.DebuggerStepThrough]
public virtual System.Threading.Tasks.Task DeferMessageAsync (Azure.Messaging.ServiceBus.ServiceBusReceivedMessage message, System.Collections.Generic.IDictionary<string,object> propertiesToModify = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
Azure.Messaging.ServiceBus.ServiceBusReceivedMessage
message
The Azure.Messaging.ServiceBus.ServiceBusReceivedMessage to defer. |
System.Collections.Generic.IDictionary<System.String,System.Object>
propertiesToModify
The properties of the message to modify while deferring the message. |
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
In order to receive this message again in the future, you will need to save the Azure.Messaging.ServiceBus.ServiceBusReceivedMessage.SequenceNumber and receive it using Azure.Messaging.ServiceBus.ServiceBusReceiver.ReceiveDeferredMessageAsync(System.Int64,System.Threading.CancellationToken). Deferring messages does not impact message's expiration, meaning that deferred messages can still expire. This operation can only be performed on messages that were received by this receiver.
Exceptions
Azure.Messaging.ServiceBus.ServiceBusException
|
RenewMessageLockAsync(ServiceBusReceivedMessage, CancellationToken)
Renews the lock on the message. The lock will be renewed based on the setting specified on the queue.
Declaration
[System.Diagnostics.DebuggerStepThrough]
public virtual System.Threading.Tasks.Task RenewMessageLockAsync (Azure.Messaging.ServiceBus.ServiceBusReceivedMessage message, System.Threading.CancellationToken cancellationToken = null);
Parameters
Azure.Messaging.ServiceBus.ServiceBusReceivedMessage
message
The Azure.Messaging.ServiceBus.ServiceBusReceivedMessage to renew the lock for. |
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 a message is received in Azure.Messaging.ServiceBus.ServiceBusReceiveMode.PeekLock mode, the message is locked on the server for this receiver instance for a duration as specified during the Queue/Subscription creation (LockDuration). If processing of the message requires longer than this duration, the lock needs to be renewed. For each renewal, it resets the time the message is locked by the LockDuration set on the Entity.
Exceptions
Azure.Messaging.ServiceBus.ServiceBusException
The lock for the message has expired or the message has already been completed. The Azure.Messaging.ServiceBus.ServiceBusException.Reason will be set to Azure.Messaging.ServiceBus.ServiceBusFailureReason.MessageLockLost in this case. |