Closed hjalle closed 2 months ago
Any progress/ideas regarding this one?
@mookid8000 I hit the same issue when using ASB NativeDeadlettering and new error handling.
As far as I can see, the issue stem from the decision of the RetryStep to create a 'nested' TransactionContext to handle the error. This makes sense if the ErrorHandling wants to Send a new Message to a separate Queue and thus Complete() that sub-transaction.
My suggestion is to move the nested transaction handling into the IErrorHandling responsabilities, depending on how ErrorHandling wants to, well, handle it. The DeadletterQueueErrorHandler would create its own Transaction, ASBNativeDeadletter would not.
The change is 'subtle' as IErrorHandling interface would not change, but parameters would change meanings:
IErrorHandler.HandlePoisonMessage(TransportMessage transportMessage, ITransactionContext transactionContext, ExceptionInfo exception);
interface would not change, but the RetryStep would pass the main Transaction.using var scope = new RebusTransactionScope();
What still troubles me is that the ASBNativeDeadlettering does "complete" the original transaction implicitly as the OriginalMessage is lost. On top of the 2 points above, I'd suggest also to change the ASB NativeDeadlettering to register an handler on the TransactionContext to be executed when the RetryStep complete the Transaction, not immediatly.
If the approach is correct, I can prepare PR.
Have you solved this in another way or are you also waiting for a solution @AndreaCuneo? I think your proposed solution might work. I'd like to see it solved somehow at least
@hjalle Waiting for @mookid8000 to confirm before making a PR.
Its a bit of a blocker for me upgrading to rebus 8 as I'm relying on dead lettering. Is it possible for @mookid8000 to perhaps take a glance at the suggestion or perhaps come up with another idea? I could give it a go but I guess it would be nice to hear if theres work in progress or if you have any ideas.
Hi @AndreaCuneo , sorry for being so slow to get back to this issue! π I think your suggestion of letting DeadletterQueueErrorHandler create its own RebusTransactionScope for its own internal use is good! π If you have it ready, please do send a PR and I'll review it quickly.
Hi @mookid8000 no worries, thanks for the library, as always.
I can prepare the PR this weekend, quite busy myself too :)
.........and by "quickly" I mean now π it's out as Rebus 8.3.0 on NuGet org now!
Thanks for fixing it!
Hi,
The old "SimpleRetryStrategy" never created a new RebusTransactionScope before dispatching the message to the errorHandler:
The new DefaultRetryStrategy does:
In Rebus.AzureServiceBus the transactionContext.Items are read, but since its a new transactioncontext with the new retrystep, nothing is found:
which in turn just "elses out" and uses the default error handler.
I'm not really sure what the preferred way to solve this would be, thus making an issue instead of a PR.