Class QueueService<T>
Provides functionalities to interact with an Amazon SQS queue for a specified message type
T.
Inherited Members
Namespace: Innovt.Cloud.AWS.SQS
Assembly: Innovt.Cloud.AWS.SQS.dll
Syntax
public class QueueService<T> : AwsBaseService, IDisposable, IQueueService<T> where T : IQueueMessage
Type Parameters
| Name | Description |
|---|---|
| T | Type of the messages in the queue, must implement IQueueMessage. |
Constructors
| Edit this page View SourceQueueService(ILogger, IAwsConfiguration, string, ISerializer)
Initializes a new instance of the QueueService<T> class.
Declaration
public QueueService(ILogger logger, IAwsConfiguration configuration, string queueName = null, ISerializer serializer = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ILogger | logger | Logger instance. |
| IAwsConfiguration | configuration | AWS configuration. |
| string | queueName | Optional queue name, defaults to the name of type |
| ISerializer | serializer | Custom serializer (optional). |
QueueService(ILogger, IAwsConfiguration, string, string, ISerializer)
Initializes a new instance of the QueueService<T> class.
Declaration
public QueueService(ILogger logger, IAwsConfiguration configuration, string region, string queueName = null, ISerializer serializer = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ILogger | logger | Logger instance. |
| IAwsConfiguration | configuration | AWS configuration. |
| string | region | |
| string | queueName | Optional queue name, defaults to the name of type |
| ISerializer | serializer | Custom serializer (optional). |
Properties
| Edit this page View SourceQueueName
Gets the name of the queue.
Declaration
public string QueueName { get; protected set; }
Property Value
| Type | Description |
|---|---|
| string |
QueueUrl
Gets the URL of the queue.
Declaration
public string QueueUrl { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
| Edit this page View SourceApproximateMessageCountAsync(CancellationToken)
Retrieves the approximate message count of the queue asynchronously.
Declaration
public Task<int> ApproximateMessageCountAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Cancellation token (optional). |
Returns
| Type | Description |
|---|---|
| Task<int> | The approximate message count of the queue. |
CreateIfNotExistAsync(CancellationToken)
Creates the queue if it does not exist asynchronously.
Declaration
public Task CreateIfNotExistAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Cancellation token (optional). |
Returns
| Type | Description |
|---|---|
| Task | A task representing the asynchronous operation. |
DeQueueAsync(string, CancellationToken)
Dequeues a message asynchronously from the queue using the provided pop receipt.
Declaration
public Task DeQueueAsync(string popReceipt, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | popReceipt | The pop receipt of the message to be dequeued. |
| CancellationToken | cancellationToken | Cancellation token (optional). |
Returns
| Type | Description |
|---|---|
| Task | A task representing the asynchronous operation. |
DisposeServices()
Disposes of the Amazon SQS client.
Declaration
protected override void DisposeServices()
Overrides
| Edit this page View SourceEnQueueAsync<TK>(TK, int?, CancellationToken)
Declaration
public Task<string> EnQueueAsync<TK>(TK message, int? visibilityTimeoutInSeconds = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TK | message | |
| int? | visibilityTimeoutInSeconds | |
| CancellationToken | cancellationToken |
, you can't set
per message. You can set this parameter only on a queue level. |
Returns
| Type | Description |
|---|---|
| Task<string> |
Type Parameters
| Name | Description |
|---|---|
| TK |
EnQueueBatchAsync(IEnumerable<MessageBatchRequest>, int?, CancellationToken)
Enqueues a batch of messages asynchronously to the queue.
Declaration
public Task<IList<MessageQueueResult>> EnQueueBatchAsync(IEnumerable<MessageBatchRequest> message, int? delaySeconds = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<MessageBatchRequest> | message | The messages to be enqueued. |
| int? | delaySeconds | The delay in seconds for message delivery (optional). |
| CancellationToken | cancellationToken | Cancellation token (optional). |
Returns
| Type | Description |
|---|---|
| Task<IList<MessageQueueResult>> | A list of message queue results indicating success or failure for each message. |
GetMessagesAsync(int, int?, int?, CancellationToken)
Enable user to receive messages
Declaration
public Task<IList<T>> GetMessagesAsync(int quantity, int? waitTimeInSeconds = null, int? visibilityTimeoutInSeconds = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | quantity | 1-10 |
| int? | waitTimeInSeconds | To enable long pooling |
| int? | visibilityTimeoutInSeconds | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<IList<T>> |