Share via


IReliableQueue<T>.EnqueueAsync Method

Definition

Overloads

EnqueueAsync(ITransaction, T)

Adds an object to the end of the reliable queue.

EnqueueAsync(ITransaction, T, TimeSpan, CancellationToken)

Adds an object to the end of the reliable queue.

EnqueueAsync(ITransaction, T)

Adds an object to the end of the reliable queue.

public System.Threading.Tasks.Task EnqueueAsync (Microsoft.ServiceFabric.Data.ITransaction tx, T item);
abstract member EnqueueAsync : Microsoft.ServiceFabric.Data.ITransaction * 'T -> System.Threading.Tasks.Task
Public Function EnqueueAsync (tx As ITransaction, item As T) As Task

Parameters

tx
ITransaction

Transaction to associate this operation with.

item
T

The object to add to the end of the queue. The value can be null for reference types.

Returns

Task that represents the asynchronous enqueue operation.

Exceptions

tx is null.

The operation failed to complete within the default timeout.

The exception that is thrown when the is not in .

The transaction has been internally faulted by the system. Retry the operation on a new transaction

Thrown when a method call is invalid for the object's current state. Example, transaction used is already terminated: committed or aborted by the user. If this exception is thrown, it is highly likely that there is a bug in the service code of the use of transactions.

Remarks

If a retriable exception is thrown by this method, it is recommended to dispose the transaction tx and try again with a new transaction.

Applies to

EnqueueAsync(ITransaction, T, TimeSpan, CancellationToken)

Adds an object to the end of the reliable queue.

public System.Threading.Tasks.Task EnqueueAsync (Microsoft.ServiceFabric.Data.ITransaction tx, T item, TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
abstract member EnqueueAsync : Microsoft.ServiceFabric.Data.ITransaction * 'T * TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function EnqueueAsync (tx As ITransaction, item As T, timeout As TimeSpan, cancellationToken As CancellationToken) As Task

Parameters

tx
ITransaction

Transaction to associate this operation with.

item
T

The object to add to the end of the queue. The value can be null for reference types.

timeout
TimeSpan

The amount of time to wait for the operation to complete before throwing a TimeoutException. Primarily used to prevent deadlocks. The default is 4 seconds.

cancellationToken
CancellationToken

The token to monitor for cancellation requests. The default is None.

Returns

Task that represents the asynchronous enqueue operation.

Exceptions

tx is null.

timeout is negative.

The operation failed to complete within the given timeout.

The operation was canceled.

The exception that is thrown when the is not in .

The transaction has been internally faulted by the system. Retry the operation on a new transaction

Thrown when a method call is invalid for the object's current state. Example, transaction used is already terminated: committed or aborted by the user. If this exception is thrown, it is highly likely that there is a bug in the service code of the use of transactions.

Remarks

If a retriable exception is thrown by this method, it is recommended to dispose the transaction tx and try again with a new transaction.

Applies to