Skip to content
This repository was archived by the owner on Apr 29, 2022. It is now read-only.

Commit 26b3440

Browse files
author
Anton Vorontsov
committed
Added StopConsuming documentation.
1 parent 0edcc10 commit 26b3440

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

docs/message-consumption.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ You can register `IHostedService` and inject an instance of `IQueueService` into
3333
services.AddSingleton<IHostedService, ConsumingService>();
3434
```
3535

36-
And then simply call `StartConsuming` so a consumer can work in the background.
36+
Then simply call `StartConsuming` so a consumer can work in the background. There is also an option which allows you to stop consuming messages - method `StopConsuming` which you can use any time you want to pause a message consumption for any reason.
3737

3838
```c#
3939
public class ConsumingService : IHostedService
@@ -59,6 +59,7 @@ public class ConsumingService : IHostedService
5959
public Task StopAsync(CancellationToken cancellationToken)
6060
{
6161
_logger.LogInformation("Stopping consuming.");
62+
_queueService.StopConsuming();
6263
return Task.CompletedTask;
6364
}
6465
}

src/RabbitMQ.Client.Core.DependencyInjection/Services/QueueService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public sealed class QueueService : IQueueService, IDisposable
3333
readonly IEnumerable<RabbitMqExchange> _exchanges;
3434
readonly ILogger<QueueService> _logger;
3535

36-
IEnumerable<string> _consumerTags;
36+
IEnumerable<string> _consumerTags = new List<string>();
3737
bool _consumingStarted;
3838
readonly object _lock = new object();
3939

0 commit comments

Comments
 (0)