Skip to content

Commit 5272baa

Browse files
authored
Improve error handling in Service Bus listener (#4)
* Improve error handling in Service Bus listener Enhanced the ProcessErrorAsync handler to log specific warnings for ServiceBusException cases such as MessagingEntityNotFound and ServiceCommunicationProblem, providing more granular logging and better diagnostics.
1 parent 26cb9df commit 5272baa

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

AzureServiceBusQueueListener.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,28 @@ await retryPolicy.ExecuteAsync(async () =>
121121

122122
_processor.ProcessErrorAsync += args =>
123123
{
124-
_logger.LogError(args.Exception, "Message handler error");
124+
if (args.Exception is ServiceBusException sbex)
125+
{
126+
if (sbex.Reason == ServiceBusFailureReason.MessagingEntityNotFound)
127+
{
128+
_logger.LogWarning("Entity not found while processing.");
129+
}
130+
else if (sbex.Reason == ServiceBusFailureReason.ServiceCommunicationProblem)
131+
{
132+
_logger.LogWarning("Service communication problem - emulator not ready.");
133+
}
134+
else
135+
{
136+
_logger.LogWarning("Service Bus error: {Reason}", sbex.Reason);
137+
}
138+
}
139+
else
140+
{
141+
_logger.LogError(args.Exception, "Message handler error");
142+
}
143+
125144
return Task.CompletedTask;
126145
};
127-
128146
await _processor.StartProcessingAsync(cancellationToken);
129147
}
130148

DotQueue.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Nullable>enable</Nullable>
77
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
88
<PackageId>DotQueue</PackageId>
9-
<Version>1.0.0</Version>
9+
<Version>1.0.1</Version>
1010
<Authors>Alexander Kulyabin</Authors>
1111
<Company>Zionet</Company>
1212
<Description>Generic queue listener</Description>

0 commit comments

Comments
 (0)