Azure / azure-service-bus-dotnet

☁️ .NET Standard client library for Azure Service Bus
https://azure.microsoft.com/services/service-bus
Other
235 stars 120 forks source link

Message handler encountered an exception System.InvalidOperationException #628

Closed MaherJendoubi closed 5 years ago

MaherJendoubi commented 5 years ago

Actual Behavior

I run the publish part of the sample Get started with Service Bus topics tutorial without any issue. But when I run the subscribe part, I get the following error:

Message handler encountered an exception System.InvalidOperationException: It is not possible for an entity that requires sessions to create a non-sessionful message receiver. TrackingId:cf62dcc7-0884-4909-ab96-5701c09b55be_B7, SystemTracker:sbns2019:Topic:basictopic|subscription1, Timestamp:2019-01-06T19:13:28 TrackingId:3beb9ab0f86c4f03a7147b69398bb1fa_G0, SystemTracker:gateway5, Timestamp:2019-01-06T19:13:28 at Microsoft.Azure.ServiceBus.Core.MessageReceiver.OnReceiveAsync(Int32 maxMessageCount, TimeSpan serverWaitTime) in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\Core\MessageReceiver.cs:line 1068 at Microsoft.Azure.ServiceBus.Core.MessageReceiver.<>c__DisplayClass64_0.<b__0>d.MoveNext() in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\Core\MessageReceiver.cs:line 375 --- End of stack trace from previous location where exception was thrown --- at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func1 operation, TimeSpan operationTimeout) in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\RetryPolicy.cs:line 85 at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func1 operation, TimeSpan operationTimeout) in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\RetryPolicy.cs:line 107 at Microsoft.Azure.ServiceBus.Core.MessageReceiver.ReceiveAsync(Int32 maxMessageCount, TimeSpan operationTimeout) in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\Core\MessageReceiver.cs:line 378 at Microsoft.Azure.ServiceBus.Core.MessageReceiver.ReceiveAsync(TimeSpan operationTimeout) in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\Core\MessageReceiver.cs:line 323 at Microsoft.Azure.ServiceBus.MessageReceivePump.MessagePumpTaskAsync() in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\MessageReceivePump.cs:line 64. Exception context for troubleshooting:

image

Expected Behavior

  1. The message count should be zero.
  2. The current size should be also zero Kb.

Versions

Runtime Environment: OS Name: Windows OS Version: 10.0.17134 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.2.101\

Host (useful for support): Version: 2.2.0 Commit: 1249f08fed

.NET Core SDKs installed: 2.1.600-preview-009426 [C:\Program Files\dotnet\sdk] 2.2.101 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

dotnet --list-sdks 2.1.600-preview-009426 [C:\Program Files\dotnet\sdk] 2.2.101 [C:\Program Files\dotnet\sdk]

SeanFeldman commented 5 years ago

It is not possible for an entity that requires sessions to create a non-sessionful message receiver. TrackingId:cf62dcc7-0884-4909-ab96-5701c09b55be_B7, SystemTracker:ticketing-application:Topic:basictopic|subscription1

The sample is creating a non-sessioned receiver to receive from Sunscription1 which happened to be created as session-based entity. That won't work. Delete the subscription and recreate it w/o enabling sessions.

MaherJendoubi commented 5 years ago

@SeanFeldman it works! Thanks a lot for the help.

image