rebus-org / Rebus

:bus: Simple and lean service bus implementation for .NET
https://mookid.dk/category/rebus
Other
2.26k stars 353 forks source link

Could not find the current transaction context when sending multiple messages within a Handle #1112

Closed mindisk closed 10 months ago

mindisk commented 10 months ago

Hello,

I am experiencing some weird and interesting behavior when using Rebus >=7.1.1 regarding transactions.

You are welcome to correct me of how we use Rebus.

I have have wrapped IBus instance and implemented the following methods for publishing messages and replying to requests. In PublishMessageAsync I use transaction scope. I did that to fix some issues I occasionally used to face where I would require to interact with AmbientTransactionScope to unassigned current transaction and then assign it back.

public async Task PublishMessageAsync(object message)
{
     using var transactionScope = new RebusTransactionScope();
     await Bus.Publish(message, _rebusHeaders);
     await transactionScope.CompleteAsync();
}
public Task ReplyMessageAsync(object message)
{
      return Bus.Reply(message, _rebusHeaders);
}

Now, I have a Handle that essentially, receive a request, publishes an command and sends a reply. Prior >=v7.1.1 it worked as expected. No errors and all messages have been sent.

public async Task Handle(OrderPizzaRequest request)
{
     // This here works perfectly fine using Rebus 7.1.0
     // But explodes using 7.1.1

      // Notify kitchen to prepare the pizza.... <--- This breaks everything using Rebus 7.1.1
     await _messageBus.PublishMessageAsync(new PreparePizzaCommand(request.OrderDetails));

     // Reply to customer...
     await _messageBus.ReplyMessageAsync(request.CreateResponse());
}

However, with >=7.1.1, I started getting errors. Once I publish the command and attempt to reply, I am getting this error. It seems, that inner transaction that is bounded to the request is gone after we punish the command. If we do not publish the command, it works OK.

Is this expected behavior?

[DBG] Rebus.Pipeline.Send.SendOutgoingMessageStep (.NET ThreadPool Worker): Sending OrderPizzaRequest -> "OrderPizzaRequest, rebus-testing@RebusTopics"
[DBG] Rebus.Pipeline.Send.SendOutgoingMessageStep (.NET ThreadPool Worker): Sending PreparePizzaCommand -> "PreparePizzaCommand, rebus-testing@RebusTopics"
Starting to prepare Large pepperoni
[DBG] Rebus.Pipeline.Receive.DispatchIncomingMessageStep (.NET ThreadPool Worker): Dispatching "PreparePizzaCommand, rebus-testing" "84bb7036-4036-462e-9f43-39b1215b71ca" to 1 handlers took 17 ms
[WRN] Rebus.Retry.ErrorTracking.InMemErrorTracker (.NET ThreadPool Worker): Unhandled exception 1 while handling message with ID "request-reply_b166c820-61da-4564-b609-4fcb6548888c"
System.InvalidOperationException: Could not find the current transaction context - this might happen if you try to reply to a message outside of a message handler
   at Rebus.Bus.RebusBus.Reply(Object replyMessage, IDictionary`2 optionalHeaders)
   at HandlePizzaOrderRequest.Handle(OrderPizzaRequest request) in C:\Users\mik\Downloads\rebus-testing\rebus-testing\Program.cs:line 102
   at Rebus.Pipeline.Receive.HandlerInvoker`1.Invoke()
   at Rebus.Pipeline.Receive.DispatchIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Sagas.LoadSagaDataStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.ActivateHandlersStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Internals.ReplyHandlerStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleRoutingSlipsStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.DeserializeIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.DataBus.ClaimCheck.HydrateIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleDeferredMessagesStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.Simple.SimpleRetryStrategyStep.DispatchWithTrackerIdentifier(Func`1 next, String identifierToTrackMessageBy, ITransactionContext transactionContext, String messageId, String secondLevelMessageId)
[DBG] Rebus.Pipeline.Send.SendOutgoingMessageStep (.NET ThreadPool Worker): Sending PreparePizzaCommand -> "PreparePizzaCommand, rebus-testing@RebusTopics"
Starting to prepare Large pepperoni
[DBG] Rebus.Pipeline.Receive.DispatchIncomingMessageStep (.NET ThreadPool Worker): Dispatching "PreparePizzaCommand, rebus-testing" "19e3b172-96f9-4670-8f20-a6dba98484d0" to 1 handlers took 2 ms
[WRN] Rebus.Retry.ErrorTracking.InMemErrorTracker (.NET ThreadPool Worker): Unhandled exception 2 while handling message with ID "request-reply_b166c820-61da-4564-b609-4fcb6548888c"
System.InvalidOperationException: Could not find the current transaction context - this might happen if you try to reply to a message outside of a message handler
   at Rebus.Bus.RebusBus.Reply(Object replyMessage, IDictionary`2 optionalHeaders)
   at HandlePizzaOrderRequest.Handle(OrderPizzaRequest request) in C:\Users\mik\Downloads\rebus-testing\rebus-testing\Program.cs:line 102
   at Rebus.Pipeline.Receive.HandlerInvoker`1.Invoke()
   at Rebus.Pipeline.Receive.DispatchIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Sagas.LoadSagaDataStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.ActivateHandlersStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Internals.ReplyHandlerStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleRoutingSlipsStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.DeserializeIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.DataBus.ClaimCheck.HydrateIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleDeferredMessagesStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.Simple.SimpleRetryStrategyStep.DispatchWithTrackerIdentifier(Func`1 next, String identifierToTrackMessageBy, ITransactionContext transactionContext, String messageId, String secondLevelMessageId)
[DBG] Rebus.Pipeline.Send.SendOutgoingMessageStep (.NET ThreadPool Worker): Sending PreparePizzaCommand -> "PreparePizzaCommand, rebus-testing@RebusTopics"
Starting to prepare Large pepperoni
[DBG] Rebus.Pipeline.Receive.DispatchIncomingMessageStep (.NET ThreadPool Worker): Dispatching "PreparePizzaCommand, rebus-testing" "fa3d11e6-b663-4e00-abcc-d21a7c15d2db" to 1 handlers took 16 ms
[WRN] Rebus.Retry.ErrorTracking.InMemErrorTracker (.NET ThreadPool Worker): Unhandled exception 3 while handling message with ID "request-reply_b166c820-61da-4564-b609-4fcb6548888c"
System.InvalidOperationException: Could not find the current transaction context - this might happen if you try to reply to a message outside of a message handler
   at Rebus.Bus.RebusBus.Reply(Object replyMessage, IDictionary`2 optionalHeaders)
   at HandlePizzaOrderRequest.Handle(OrderPizzaRequest request) in C:\Users\mik\Downloads\rebus-testing\rebus-testing\Program.cs:line 102
   at Rebus.Pipeline.Receive.HandlerInvoker`1.Invoke()
   at Rebus.Pipeline.Receive.DispatchIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Sagas.LoadSagaDataStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.ActivateHandlersStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Internals.ReplyHandlerStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleRoutingSlipsStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.DeserializeIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.DataBus.ClaimCheck.HydrateIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleDeferredMessagesStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.Simple.SimpleRetryStrategyStep.DispatchWithTrackerIdentifier(Func`1 next, String identifierToTrackMessageBy, ITransactionContext transactionContext, String messageId, String secondLevelMessageId)
[DBG] Rebus.Pipeline.Send.SendOutgoingMessageStep (.NET ThreadPool Worker): Sending PreparePizzaCommand -> "PreparePizzaCommand, rebus-testing@RebusTopics"
Starting to prepare Large pepperoni
[DBG] Rebus.Pipeline.Receive.DispatchIncomingMessageStep (.NET ThreadPool Worker): Dispatching "PreparePizzaCommand, rebus-testing" "b54211c5-c541-4130-a6c2-199e65f9852c" to 1 handlers took 0 ms
[WRN] Rebus.Retry.ErrorTracking.InMemErrorTracker (.NET ThreadPool Worker): Unhandled exception 4 while handling message with ID "request-reply_b166c820-61da-4564-b609-4fcb6548888c"
System.InvalidOperationException: Could not find the current transaction context - this might happen if you try to reply to a message outside of a message handler
   at Rebus.Bus.RebusBus.Reply(Object replyMessage, IDictionary`2 optionalHeaders)
   at HandlePizzaOrderRequest.Handle(OrderPizzaRequest request) in C:\Users\mik\Downloads\rebus-testing\rebus-testing\Program.cs:line 102
   at Rebus.Pipeline.Receive.HandlerInvoker`1.Invoke()
   at Rebus.Pipeline.Receive.DispatchIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Sagas.LoadSagaDataStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.ActivateHandlersStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Internals.ReplyHandlerStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleRoutingSlipsStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.DeserializeIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.DataBus.ClaimCheck.HydrateIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleDeferredMessagesStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.Simple.SimpleRetryStrategyStep.DispatchWithTrackerIdentifier(Func`1 next, String identifierToTrackMessageBy, ITransactionContext transactionContext, String messageId, String secondLevelMessageId)
[DBG] Rebus.Pipeline.Send.SendOutgoingMessageStep (.NET ThreadPool Worker): Sending PreparePizzaCommand -> "PreparePizzaCommand, rebus-testing@RebusTopics"
Starting to prepare Large pepperoni
[DBG] Rebus.Pipeline.Receive.DispatchIncomingMessageStep (.NET ThreadPool Worker): Dispatching "PreparePizzaCommand, rebus-testing" "2b0249a8-3faf-4710-8a31-2747aa3265b6" to 1 handlers took 19 ms
[WRN] Rebus.Retry.ErrorTracking.InMemErrorTracker (.NET ThreadPool Worker): Unhandled exception 5 while handling message with ID "request-reply_b166c820-61da-4564-b609-4fcb6548888c"
System.InvalidOperationException: Could not find the current transaction context - this might happen if you try to reply to a message outside of a message handler
   at Rebus.Bus.RebusBus.Reply(Object replyMessage, IDictionary`2 optionalHeaders)
   at HandlePizzaOrderRequest.Handle(OrderPizzaRequest request) in C:\Users\mik\Downloads\rebus-testing\rebus-testing\Program.cs:line 102
   at Rebus.Pipeline.Receive.HandlerInvoker`1.Invoke()
   at Rebus.Pipeline.Receive.DispatchIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Sagas.LoadSagaDataStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.ActivateHandlersStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Internals.ReplyHandlerStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleRoutingSlipsStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.DeserializeIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.DataBus.ClaimCheck.HydrateIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleDeferredMessagesStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.Simple.SimpleRetryStrategyStep.DispatchWithTrackerIdentifier(Func`1 next, String identifierToTrackMessageBy, ITransactionContext transactionContext, String messageId, String secondLevelMessageId)
[ERR] Rebus.Retry.PoisonQueues.PoisonQueueErrorHandler (.NET ThreadPool Worker): Moving message with ID "request-reply_b166c820-61da-4564-b609-4fcb6548888c" to error queue "error"
System.AggregateException: 5 unhandled exceptions (Could not find the current transaction context - this might happen if you try to reply to a message outside of a message handler) (Could not find the current transaction context - this might happen if you try to reply to a message outside of a message handler) (Could not find the current transaction context - this might happen if you try to reply to a message outside of a message handler) (Could not find the current transaction context - this might happen if you try to reply to a message outside of a message handler) (Could not find the current transaction context - this might happen if you try to reply to a message outside of a message handler)
 ---> System.InvalidOperationException: Could not find the current transaction context - this might happen if you try to reply to a message outside of a message handler
   at Rebus.Bus.RebusBus.Reply(Object replyMessage, IDictionary`2 optionalHeaders)
   at HandlePizzaOrderRequest.Handle(OrderPizzaRequest request) in C:\Users\mik\Downloads\rebus-testing\rebus-testing\Program.cs:line 102
   at Rebus.Pipeline.Receive.HandlerInvoker`1.Invoke()
   at Rebus.Pipeline.Receive.DispatchIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Sagas.LoadSagaDataStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.ActivateHandlersStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Internals.ReplyHandlerStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleRoutingSlipsStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.DeserializeIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.DataBus.ClaimCheck.HydrateIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleDeferredMessagesStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.Simple.SimpleRetryStrategyStep.DispatchWithTrackerIdentifier(Func`1 next, String identifierToTrackMessageBy, ITransactionContext transactionContext, String messageId, String secondLevelMessageId)
   --- End of inner exception stack trace ---
 ---> (Inner Exception #1) System.InvalidOperationException: Could not find the current transaction context - this might happen if you try to reply to a message outside of a message handler
   at Rebus.Bus.RebusBus.Reply(Object replyMessage, IDictionary`2 optionalHeaders)
   at HandlePizzaOrderRequest.Handle(OrderPizzaRequest request) in C:\Users\mik\Downloads\rebus-testing\rebus-testing\Program.cs:line 102
   at Rebus.Pipeline.Receive.HandlerInvoker`1.Invoke()
   at Rebus.Pipeline.Receive.DispatchIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Sagas.LoadSagaDataStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.ActivateHandlersStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Internals.ReplyHandlerStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleRoutingSlipsStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.DeserializeIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.DataBus.ClaimCheck.HydrateIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleDeferredMessagesStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.Simple.SimpleRetryStrategyStep.DispatchWithTrackerIdentifier(Func`1 next, String identifierToTrackMessageBy, ITransactionContext transactionContext, String messageId, String secondLevelMessageId)<---

 ---> (Inner Exception #2) System.InvalidOperationException: Could not find the current transaction context - this might happen if you try to reply to a message outside of a message handler
   at Rebus.Bus.RebusBus.Reply(Object replyMessage, IDictionary`2 optionalHeaders)
   at HandlePizzaOrderRequest.Handle(OrderPizzaRequest request) in C:\Users\mik\Downloads\rebus-testing\rebus-testing\Program.cs:line 102
   at Rebus.Pipeline.Receive.HandlerInvoker`1.Invoke()
   at Rebus.Pipeline.Receive.DispatchIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Sagas.LoadSagaDataStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.ActivateHandlersStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Internals.ReplyHandlerStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleRoutingSlipsStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.DeserializeIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.DataBus.ClaimCheck.HydrateIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleDeferredMessagesStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.Simple.SimpleRetryStrategyStep.DispatchWithTrackerIdentifier(Func`1 next, String identifierToTrackMessageBy, ITransactionContext transactionContext, String messageId, String secondLevelMessageId)<---

 ---> (Inner Exception #3) System.InvalidOperationException: Could not find the current transaction context - this might happen if you try to reply to a message outside of a message handler
   at Rebus.Bus.RebusBus.Reply(Object replyMessage, IDictionary`2 optionalHeaders)
   at HandlePizzaOrderRequest.Handle(OrderPizzaRequest request) in C:\Users\mik\Downloads\rebus-testing\rebus-testing\Program.cs:line 102
   at Rebus.Pipeline.Receive.HandlerInvoker`1.Invoke()
   at Rebus.Pipeline.Receive.DispatchIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Sagas.LoadSagaDataStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.ActivateHandlersStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Internals.ReplyHandlerStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleRoutingSlipsStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.DeserializeIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.DataBus.ClaimCheck.HydrateIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleDeferredMessagesStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.Simple.SimpleRetryStrategyStep.DispatchWithTrackerIdentifier(Func`1 next, String identifierToTrackMessageBy, ITransactionContext transactionContext, String messageId, String secondLevelMessageId)<---

 ---> (Inner Exception #4) System.InvalidOperationException: Could not find the current transaction context - this might happen if you try to reply to a message outside of a message handler
   at Rebus.Bus.RebusBus.Reply(Object replyMessage, IDictionary`2 optionalHeaders)
   at HandlePizzaOrderRequest.Handle(OrderPizzaRequest request) in C:\Users\mik\Downloads\rebus-testing\rebus-testing\Program.cs:line 102
   at Rebus.Pipeline.Receive.HandlerInvoker`1.Invoke()
   at Rebus.Pipeline.Receive.DispatchIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Sagas.LoadSagaDataStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.ActivateHandlersStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Internals.ReplyHandlerStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleRoutingSlipsStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.DeserializeIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.DataBus.ClaimCheck.HydrateIncomingMessageStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Pipeline.Receive.HandleDeferredMessagesStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context, Func`1 next)
   at Rebus.Retry.Simple.SimpleRetryStrategyStep.DispatchWithTrackerIdentifier(Func`1 next, String identifierToTrackMessageBy, ITransactionContext transactionContext, String messageId, String secondLevelMessageId)<---
mookid8000 commented 10 months ago

It turned out that I had introduced a bug recently in how nested RebusTransactionScopes work.

It should be fixed in Rebus 7.2.1.

Rebus 8 does not have that problem, because its TransactionContext has a different way of managing itself.

Thanks for directing my attention to this issue 🙂 👍