Fix locking in MessageSenderFactory

This commit is contained in:
Sipke Schoorstra 2020-12-21 13:54:44 +01:00
parent dd2004dd89
commit 913241732a

View file

@ -23,11 +23,11 @@ namespace Elsa.Activities.AzureServiceBus.Services
public async Task<IMessageSender> GetSenderAsync(string queueName, CancellationToken cancellationToken)
{
await _semaphore.WaitAsync(cancellationToken);
if (_senders.TryGetValue(queueName, out var messageSender))
return messageSender;
await _semaphore.WaitAsync(cancellationToken);
try
{
await _managementClient.EnsureQueueExistsAsync(queueName, cancellationToken);