Skip to content

Commit

Permalink
support disabling ddl
Browse files Browse the repository at this point in the history
  • Loading branch information
tmasternak authored and ramonsmits committed Nov 6, 2024
1 parent ed86966 commit 0fb5844
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/NServiceBus.Transport.SQS/Configure/SqsTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ internal set
/// </summary>
public string QueueNamePrefix { get; set; }

/// <summary>
/// Disable native delayed delivery infrastructure
/// </summary>
internal bool DisableDelayedDelivery { get; set; } = false;

/// <summary>
/// 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.
Expand Down Expand Up @@ -235,6 +230,19 @@ public SqsTransport()
snsClient = DefaultClientFactories.SnsFactory();
}

/// <summary>
/// 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)
/// </summary>
/// <param name="enableDelayedDelivery">Should the delayed delivery infrastructure be created by the endpoint</param>
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)
{
Expand All @@ -253,14 +261,14 @@ public override async Task<TransportInfrastructure> 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);
}
Expand Down

0 comments on commit 0fb5844

Please sign in to comment.