Skip to content

Commit 05714b5

Browse files
committed
* Add concurrency to try to reproduce issue.
1 parent cae3e03 commit 05714b5

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

projects/Test/Integration/GH/TestGitHubIssues.cs

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ await ch.BasicPublishAsync(exchange: string.Empty, routingKey: queueName,
333333
[Fact]
334334
public async Task MaybeSomethingUpWithRateLimiter_GH1793()
335335
{
336+
const int messageCount = 16;
337+
336338
_connFactory = new ConnectionFactory
337339
{
338340
AutomaticRecoveryEnabled = true
@@ -343,7 +345,7 @@ public async Task MaybeSomethingUpWithRateLimiter_GH1793()
343345
var channelOpts = new CreateChannelOptions(
344346
publisherConfirmationsEnabled: true,
345347
publisherConfirmationTrackingEnabled: true,
346-
outstandingPublisherConfirmationsRateLimiter: new ThrottlingRateLimiter(256)
348+
outstandingPublisherConfirmationsRateLimiter: new ThrottlingRateLimiter(messageCount)
347349
);
348350

349351
_channel = await _conn.CreateChannelAsync(channelOpts);
@@ -352,22 +354,40 @@ public async Task MaybeSomethingUpWithRateLimiter_GH1793()
352354
{
353355
DeliveryMode = DeliveryModes.Persistent
354356
};
355-
int retryCount = 0;
356-
const int maxRetries = 3;
357-
while (retryCount <= maxRetries)
357+
358+
async Task PublishMessagesAsync()
358359
{
359-
try
360-
{
361-
var bytes = Encoding.UTF8.GetBytes("message");
362-
await _channel.BasicPublishAsync(string.Empty, string.Empty, true, properties, bytes);
363-
break;
364-
}
365-
catch (Exception ex)
360+
for (int i = 0; i < messageCount; i++)
366361
{
367-
retryCount++;
368-
_output.WriteLine("{0} exception: {1}", _testDisplayName, ex);
362+
int retryCount = 0;
363+
const int maxRetries = 3;
364+
while (retryCount <= maxRetries)
365+
{
366+
try
367+
{
368+
byte[] bytes = Encoding.UTF8.GetBytes("message");
369+
await _channel.BasicPublishAsync(string.Empty, string.Empty, true, properties, bytes);
370+
break;
371+
}
372+
catch (SemaphoreFullException ex0)
373+
{
374+
_output.WriteLine("{0} ex: {1}", _testDisplayName, ex0);
375+
retryCount++;
376+
}
377+
catch (PublishException)
378+
{
379+
retryCount++;
380+
}
381+
}
369382
}
370383
}
384+
385+
var publishTasks = new List<Task>();
386+
for (int i = 0; i < messageCount; i++)
387+
{
388+
publishTasks.Add(Task.Run(PublishMessagesAsync));
389+
}
390+
await Task.WhenAll(publishTasks);
371391
}
372392
}
373393
}

0 commit comments

Comments
 (0)