Particular / NServiceBus.Transport.Msmq

MSMQ transport for NServiceBus
https://docs.particular.net/nservicebus/msmq/
Other
5 stars 11 forks source link

Delayed delivery does not work when using SqlServerDelayedMessageStore without EnableInstallers #700

Closed dvdstelt closed 2 weeks ago

dvdstelt commented 2 months ago

Describe the bug

Description

For some reason, the SqlServerDelayedMessageStore copies the SQL commands from SqlConstants into internal variables but only in the Initialize method on line 111..115.

Unfortunately this Initialize method is only called when EnableInstallers has been set. Not setting EnableInstallers does not copy those commands and the entire DelayedMessages in MSQM is not working and throws continuous errors that the CommandText has not been set.

Expected behavior

That it's working?

Actual behavior

Versions

Please list the version of the relevant packages or applications in which the bug exists.

Steps to reproduce

Relevant log output

NServiceBus.Transport.Msmq.DelayedDelivery.DueDelayedMessagePoller[0]
      Failure during timeout polling.
      System.InvalidOperationException: BeginExecuteReader: CommandText property has not been initialized
         at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
         at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
         at System.Data.SqlClient.SqlCommand.BeginExecuteReaderInternal(CommandBehavior behavior, AsyncCallback callback, Object stateObject, Int32 timeout, Boolean inRetry, Boolean asyncWrite)
         at System.Data.SqlClient.SqlCommand.BeginExecuteReaderAsync(CommandBehavior behavior, AsyncCallback callback, Object stateObject)
         at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl[TArg1](Func`4 beginMethod, Func`2 endFunction, Action`1 endAction, TArg1 arg1, Object state, TaskCreationOptions creationOptions)
         at System.Threading.Tasks.TaskFactory`1.FromAsync[TArg1](Func`4 beginMethod, Func`2 endMethod, TArg1 arg1, Object state)
         at System.Data.SqlClient.SqlCommand.ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
      --- 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 NServiceBus.SqlServerDelayedMessageStore.<FetchNextDueTimeout>d__15.MoveNext() in /_/src/NServiceBus.Transport.Msmq/DelayedDelivery/Sql/SqlServerDelayedMessageStore.cs:line 140
      --- 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 NServiceBus.Transport.Msmq.DelayedDelivery.DueDelayedMessagePoller.<Poll>d__8.MoveNext() in /_/src/NServiceBus.Transport.Msmq/DelayedDelivery/DueDelayedMessagePoller.cs:line 193

Additional Information

Workarounds

Possible solutions

Additional information

ramonsmits commented 2 months ago

We've prioritized this issue near the top of our list and will work on it as soon as we can.