diff --git a/src/NServiceBus.Transport.SQS/Configure/SqsTransport.cs b/src/NServiceBus.Transport.SQS/Configure/SqsTransport.cs index 448b7e60b..eb519a1c1 100644 --- a/src/NServiceBus.Transport.SQS/Configure/SqsTransport.cs +++ b/src/NServiceBus.Transport.SQS/Configure/SqsTransport.cs @@ -57,11 +57,6 @@ internal set /// public string QueueNamePrefix { get; set; } - /// - /// Disable native delayed delivery infrastructure - /// - internal bool DisableDelayedDelivery { get; set; } = false; - /// /// Specifies a lambda function that allows to take control of the queue name generation logic. /// This is useful to overcome any limitations imposed by SQS. @@ -235,6 +230,19 @@ public SqsTransport() snsClient = DefaultClientFactories.SnsFactory(); } + /// + /// Creates a new instance of the SQS transport definition. + /// + /// Uses SQS and SNS clients created using a default constructor (based on the the settings from the environment) + /// + /// Should the delayed delivery infrastructure be created by the endpoint + public SqsTransport(bool enableDelayedDelivery) + : base(TransportTransactionMode.ReceiveOnly, enableDelayedDelivery, true, true) + { + sqsClient = DefaultClientFactories.SqsFactory(); + snsClient = DefaultClientFactories.SnsFactory(); + } + internal SqsTransport(IAmazonSQS sqsClient, IAmazonSimpleNotificationService snsClient, bool supportsPublishSubscribe) : base(TransportTransactionMode.ReceiveOnly, true, supportsPublishSubscribe, true) { @@ -253,14 +261,14 @@ public override async Task Initialize(HostSettings host AssertQueueNameGeneratorIdempotent(queueNameGenerator); var topicCache = new TopicCache(SnsClient, hostSettings.CoreSettings, eventToTopicsMappings, eventToEventsMappings, topicNameGenerator, topicNamePrefix); - var infra = new SqsTransportInfrastructure(hostSettings, receivers, SqsClient, SnsClient, QueueCache, topicCache, S3, Policies, QueueDelayTime, topicNamePrefix, DoNotWrapOutgoingMessages, !externallyManagedSqsClient, !externallyManagedSnsClient, DisableDelayedDelivery); + var infra = new SqsTransportInfrastructure(hostSettings, receivers, SqsClient, SnsClient, QueueCache, topicCache, S3, Policies, QueueDelayTime, topicNamePrefix, DoNotWrapOutgoingMessages, !externallyManagedSqsClient, !externallyManagedSnsClient, !SupportsDelayedDelivery); if (hostSettings.SetupInfrastructure) { var queueCreator = new QueueCreator(SqsClient, QueueCache, S3, maxTimeToLive, QueueDelayTime); var createQueueTasks = sendingAddresses.Select(x => queueCreator.CreateQueueIfNecessary(x, false, cancellationToken)) - .Concat(infra.Receivers.Values.Select(x => queueCreator.CreateQueueIfNecessary(x.ReceiveAddress, !DisableDelayedDelivery, cancellationToken))).ToArray(); + .Concat(infra.Receivers.Values.Select(x => queueCreator.CreateQueueIfNecessary(x.ReceiveAddress, SupportsDelayedDelivery, cancellationToken))).ToArray(); await Task.WhenAll(createQueueTasks).ConfigureAwait(false); }