Interface IAwsSqsQueueBuilder
Fluent builder interface for configuring standard AWS SQS queue settings.
public interface IAwsSqsQueueBuilder
- Extension Methods
Examples
services.AddAwsSqsTransport(sqs =>
{
sqs.ConfigureQueue(queue =>
{
queue.VisibilityTimeout(TimeSpan.FromMinutes(5))
.MessageRetentionPeriod(TimeSpan.FromDays(7))
.ReceiveWaitTimeSeconds(20)
.DelaySeconds(0)
.DeadLetterQueue(dlq =>
{
dlq.QueueArn("arn:aws:sqs:us-east-1:123456789012:my-dlq")
.MaxReceiveCount(3);
});
});
});
Remarks
This interface follows the Microsoft-style fluent builder pattern.
All methods return this for method chaining.
All values are validated against AWS SQS constraints immediately when set (fail fast). Invalid values throw ArgumentOutOfRangeException.
Methods
DeadLetterQueue(Action<IAwsSqsDeadLetterBuilder>)
Configures a dead-letter queue for failed message handling.
IAwsSqsQueueBuilder DeadLetterQueue(Action<IAwsSqsDeadLetterBuilder> configure)
Parameters
configureAction<IAwsSqsDeadLetterBuilder>The dead-letter queue configuration action.
Returns
- IAwsSqsQueueBuilder
The builder for fluent chaining.
Examples
.DeadLetterQueue(dlq =>
{
dlq.QueueArn("arn:aws:sqs:us-east-1:123456789012:my-dlq")
.MaxReceiveCount(5);
})
Remarks
Messages that fail processing after the maximum receive count are automatically moved to the dead-letter queue for later analysis or reprocessing.
Exceptions
- ArgumentNullException
Thrown when
configureis null.
DelaySeconds(int)
Sets the delay before messages become visible for consumption.
IAwsSqsQueueBuilder DelaySeconds(int seconds)
Parameters
secondsintThe delay in seconds (0-900). Default is 0 (no delay).
Returns
- IAwsSqsQueueBuilder
The builder for fluent chaining.
Remarks
Useful for implementing delayed message processing scenarios.
Exceptions
- ArgumentOutOfRangeException
Thrown when
secondsis less than 0 or greater than 900.
MessageRetentionPeriod(TimeSpan)
Sets the message retention period for the queue.
IAwsSqsQueueBuilder MessageRetentionPeriod(TimeSpan period)
Parameters
periodTimeSpanThe retention period (1 minute to 14 days). Default is 4 days.
Returns
- IAwsSqsQueueBuilder
The builder for fluent chaining.
Remarks
Messages are automatically deleted after the retention period expires.
Exceptions
- ArgumentOutOfRangeException
Thrown when
periodis less than 1 minute or greater than 14 days.
ReceiveWaitTimeSeconds(int)
Sets the receive wait time for long polling.
IAwsSqsQueueBuilder ReceiveWaitTimeSeconds(int seconds)
Parameters
secondsintThe wait time in seconds (0-20). Default is 0 (short polling).
Returns
- IAwsSqsQueueBuilder
The builder for fluent chaining.
Remarks
Long polling (1-20 seconds) is recommended as it reduces costs and allows consumers to receive messages as soon as they arrive in the queue.
Exceptions
- ArgumentOutOfRangeException
Thrown when
secondsis less than 0 or greater than 20.
VisibilityTimeout(TimeSpan)
Sets the visibility timeout for messages in the queue.
IAwsSqsQueueBuilder VisibilityTimeout(TimeSpan timeout)
Parameters
timeoutTimeSpanThe visibility timeout (0 seconds to 12 hours). Default is 30 seconds.
Returns
- IAwsSqsQueueBuilder
The builder for fluent chaining.
Remarks
The visibility timeout is the length of time that a received message is invisible to other consumers. If not processed and deleted within this time, the message becomes visible again.
Exceptions
- ArgumentOutOfRangeException
Thrown when
timeoutis less than 0 or greater than 12 hours.