Skip to content

Commit

Permalink
Minor refactoring so cancellation exceptions can be handled in a sing…
Browse files Browse the repository at this point in the history
…le try/catch block instead of having more than one

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
  • Loading branch information
WhitWaldo committed Sep 25, 2024
1 parent dd22e83 commit 521396f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Dapr.Messaging/PublishSubscribe/PublishSubscribeReceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ public async Task SubscribeAsync(CancellationToken cancellationToken = default)
//Retrieve the messages from the sidecar and write to the messages channel
_ = FetchDataFromSidecarAsync(stream, channel.Writer, cancellationToken);

//Processes each acknowledgement from the acknowledgement channel reader as it's populated
await foreach (var acknowledgement in acknowledgements.Reader.ReadAllAsync(cancellationToken))
{
await ProcessAcknowledgementAsync(acknowledgement);
}

//Read the messages one-by-one out of the messages channel
try
{
//Processes each acknowledgement from the acknowledgement channel reader as it's populated
await foreach (var acknowledgement in acknowledgements.Reader.ReadAllAsync(cancellationToken))
{
await ProcessAcknowledgementAsync(acknowledgement);
}

//Read the messages one-by-one out of the messages channel
while (await channel.Reader.WaitToReadAsync(cancellationToken))
{
while (channel.Reader.TryRead(out var message))
Expand Down

0 comments on commit 521396f

Please sign in to comment.