rebus-org / Rebus.AzureServiceBus

:bus: Azure Service Bus transport for Rebus
https://mookid.dk/category/rebus
Other
33 stars 20 forks source link

Lock Expiration #13

Closed mpaul31 closed 5 years ago

mpaul31 commented 5 years ago

Hello,

I am seeing the following exception happen in my message handler when I have a break point set and wait for about 30 seconds. I know rebus sets the default lock timeout to five minutes but I can't figure out why this would cause an exception. Any help would be greatly appreciated.

        public async Task Handle(CreateUser message)
        {
            Console.WriteLine(message.Name);

            string msg = $"Hello {message.Name} from Rebus";

            await this.bus.Publish(new UserCreated { Name = msg, CreatedAt = DateTime.UtcNow });
        }
[ERR] Rebus.Workers.ThreadPoolBased.ThreadPoolWorker (Thread #4): Unhandled exception in thread pool worker
Rebus.Exceptions.RebusApplicationException: Could not abandon message with ID cff3dcc0-c042-4510-b5fe-57d44d80fbb6 and lock token 30a3b88e-19f4-4d49-87ed-8ee951350095 ---> Microsoft.Azure.ServiceBus.MessageLockLostException: The lock supplied is invalid. Either the lock expired, or the message has already been removed from the queue, or was received by a different receiver instance.
   at Microsoft.Azure.ServiceBus.Core.MessageReceiver.<DisposeMessagesAsync>d__99.MoveNext() in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\Core\MessageReceiver.cs:line 1425
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.ServiceBus.RetryPolicy.<RunOperation>d__20.MoveNext() in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\RetryPolicy.cs:line 86
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Azure.ServiceBus.RetryPolicy.<RunOperation>d__20.MoveNext() in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\RetryPolicy.cs:line 70
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.ServiceBus.Core.MessageReceiver.<AbandonAsync>d__69.MoveNext() in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\Core\MessageReceiver.cs:line 582
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Rebus.AzureServiceBus.AzureServiceBusTransport.<>c__DisplayClass28_0.<<Receive>b__6>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Rebus.Internals.AsyncHelpers.CustomSynchronizationContext.<<Run>b__7_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Rebus.Internals.AsyncHelpers.CustomSynchronizationContext.Run()
   at Rebus.Internals.AsyncHelpers.RunSync(Func`1 task)
   at Rebus.AzureServiceBus.AzureServiceBusTransport.<>c__DisplayClass28_0.<Receive>b__1()
   --- End of inner exception stack trace ---
   at Rebus.AzureServiceBus.AzureServiceBusTransport.<>c__DisplayClass28_0.<Receive>b__1()
   at Rebus.Transport.TransactionContext.Invoke(ConcurrentQueue`1 actions)
   at Rebus.Transport.TransactionContext.RaiseAborted()
   at Rebus.Transport.TransactionContext.Dispose()
   at Rebus.Workers.ThreadPoolBased.ThreadPoolWorker.<TryAsyncReceive>d__16.MoveNext()
mpaul31 commented 5 years ago

oh geez nevermind. this was a queue i manually created and the portal shows the lock duration of 30 seconds. :)

however, one of the queues rebus configured it set to 1 minute. i thought i read somewhere it defaults it to 5 minutes. i can always change it myself, just want to make sure when i educate others around me I know indeed what is happening behind the scenes.

mookid8000 commented 5 years ago

😄 I'm guessing you got it figured out