Skip to content

Commit b4d63bc

Browse files
committed
Cleaning up code.
1 parent f397358 commit b4d63bc

File tree

3 files changed

+14
-25
lines changed

3 files changed

+14
-25
lines changed

RabbitMQTest/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static async Task Main(string[] args)
3434
subscriber.QueueBind("testqueue", "test", "myawesome.routing.key");
3535
subscriber.BasicConsume("testqueue", false, "testconsumer", asyncListener);
3636

37-
byte[] payload = new byte[512];
37+
byte[] payload = new byte[16384];
3838
var batchPublish = Task.Run(async () =>
3939
{
4040
while (messagesSent < batchesToSend * itemsPerBatch)
@@ -49,7 +49,7 @@ static async Task Main(string[] args)
4949
}
5050
batch.Publish();
5151
messagesSent += itemsPerBatch;
52-
await publisher.WaitForConfirmsOrDieAsync();
52+
publisher.WaitForConfirmsOrDie();
5353
}
5454
});
5555

projects/client/RabbitMQ.Client/src/client/api/IModel.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,6 @@ void QueueDeclareNoWait(string queue, bool durable,
496496
/// </remarks>
497497
[AmqpMethodDoNotImplement(null)]
498498
bool WaitForConfirms();
499-
[AmqpMethodDoNotImplement(null)]
500-
Task<bool> WaitForConfirmsAsync();
501499

502500
/// <summary>
503501
/// Wait until all published messages have been confirmed.
@@ -533,8 +531,6 @@ void QueueDeclareNoWait(string queue, bool durable,
533531
/// </remarks>
534532
[AmqpMethodDoNotImplement(null)]
535533
bool WaitForConfirms(TimeSpan timeout, out bool timedOut);
536-
[AmqpMethodDoNotImplement(null)]
537-
Task<(bool onlyAcksReceived, bool timedOut)> WaitForConfirmsAsync(TimeSpan timeout);
538534

539535
/// <summary>
540536
/// Wait until all published messages have been confirmed.
@@ -546,8 +542,6 @@ void QueueDeclareNoWait(string queue, bool durable,
546542
/// </remarks>
547543
[AmqpMethodDoNotImplement(null)]
548544
void WaitForConfirmsOrDie();
549-
[AmqpMethodDoNotImplement(null)]
550-
Task WaitForConfirmsOrDieAsync();
551545

552546
/// <summary>
553547
/// Wait until all published messages have been confirmed.
@@ -559,8 +553,6 @@ void QueueDeclareNoWait(string queue, bool durable,
559553
/// </remarks>
560554
[AmqpMethodDoNotImplement(null)]
561555
void WaitForConfirmsOrDie(TimeSpan timeout);
562-
[AmqpMethodDoNotImplement(null)]
563-
Task WaitForConfirmsOrDieAsync(TimeSpan timeout);
564556

565557
/// <summary>
566558
/// Amount of time protocol operations (e.g. <code>queue.declare</code>) are allowed to take before

projects/client/RabbitMQ.Client/src/client/impl/ModelBase.cs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public void Close(ShutdownEventArgs reason, bool abort)
273273
{
274274
var k = new ShutdownContinuation();
275275
ModelShutdown += k.OnConnectionShutdown;
276-
_connectionClosingCancellation.Cancel();
276+
_connectionClosingCancellation.Cancel(false);
277277

278278
try
279279
{
@@ -284,7 +284,11 @@ public void Close(ShutdownEventArgs reason, bool abort)
284284
}
285285
k.Wait(TimeSpan.FromMilliseconds(10000));
286286
ConsumerDispatcher.Shutdown(this);
287-
_multipleConfirmCleanup.Wait();
287+
try
288+
{
289+
_multipleConfirmCleanup.Wait();
290+
}
291+
catch (AggregateException) { }
288292
}
289293
catch (AlreadyClosedException)
290294
{
@@ -1628,23 +1632,16 @@ public async Task CleanupUnconfirmedTagsAsync()
16281632
{
16291633
while (!_connectionClosingCancellation.IsCancellationRequested)
16301634
{
1631-
try
1635+
await _multipleConfirmLock.WaitAsync(_connectionClosingCancellation.Token).ConfigureAwait(false);
1636+
foreach (ulong key in m_unconfirmedSet.Keys)
16321637
{
1633-
await _multipleConfirmLock.WaitAsync(_connectionClosingCancellation.Token).ConfigureAwait(false);
1634-
foreach (ulong key in m_unconfirmedSet.Keys)
1638+
if (key <= _highestDeliveryTag)
16351639
{
1636-
if (key <= _highestDeliveryTag)
1637-
{
1638-
m_unconfirmedSet.TryRemove(key, out _);
1639-
}
1640+
m_unconfirmedSet.TryRemove(key, out _);
16401641
}
1641-
1642-
TriggerAllOutstandingCompleted();
1643-
}
1644-
catch (TaskCanceledException)
1645-
{
1646-
// Swallow the task cancel exception since the model is being closed.
16471642
}
1643+
1644+
TriggerAllOutstandingCompleted();
16481645
}
16491646
}
16501647

0 commit comments

Comments
 (0)