Skip to content

Commit 6d37cb0

Browse files
authored
Log when work item consumer stops (#5673)
1 parent d8b5d88 commit 6d37cb0

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/ProductConstructionService/ProductConstructionService.WorkItems/WorkItemConsumer.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,18 @@ protected override async Task ExecuteAsync(CancellationToken cancellationToken)
4343

4444
while (!cancellationToken.IsCancellationRequested)
4545
{
46-
await using (WorkItemScope workItemScope = await _scopeManager.BeginWorkItemScopeWhenReadyAsync())
46+
WorkItemScope workItemScope;
47+
try
48+
{
49+
workItemScope = await _scopeManager.BeginWorkItemScopeWhenReadyAsync();
50+
}
51+
catch (Exception ex)
52+
{
53+
_logger.LogCritical(ex, "Consumer {consumerId} failed to begin work item scope", _consumerId);
54+
throw;
55+
}
56+
57+
await using (workItemScope)
4758
{
4859
if (cancellationToken.IsCancellationRequested)
4960
{
@@ -64,6 +75,8 @@ protected override async Task ExecuteAsync(CancellationToken cancellationToken)
6475
}
6576
}
6677
}
78+
79+
_logger.LogInformation("Consumer {consumerId} stopping processing PCS queue {queueName}", _consumerId, _queueName);
6780
}
6881

6982
private async Task ReadAndProcessWorkItemAsync(QueueClient queueClient, WorkItemScope workItemScope, CancellationToken cancellationToken)

0 commit comments

Comments
 (0)