0

I am executing a series of SQL Inserts from a MassTransit Handler. I create a Transaction Scope, so all Inserts pass or fail. Works with zero issues when RabbitMQ is the Bus.

On switching to Azure Service Bus, introducing a Transaction Scope for SQL Server is a problem for Azure Service Bus, who hooks into it and will not let go.

Errors thrown

  1. Require IsolationLevel.Serializable
  2. Local transactions are not supported with other resource managers/DTC

In any case the code in not working anymore with the Trnx Scope set as it was.

I had to Suppress the Transaction Scope to get the code to work, but that is not the solution.

I want to know how to prevent Azure Service Bus from engaging in a Transaction Scope explicitly meant for SQL Server - do not assume things.

Is there a way to signal Service Bus from MassTransit not to engage in the SQL Transaction scope?

I am sure others have run into this - look forward to the solutions.

1
  • please the code in text /link you tried in the above question. Commented Aug 9, 2024 at 3:35

1 Answer 1

1

I believe the following will prevent Service Bus from participating in the ambient transaction:

using (var ts = new TransactionScope(TransactionScopeOption.Suppress, TransactionScopeAsyncFlowOption.Enabled))
{
    // Example Service Bus operation
    await _sender.SendMessageAsync(...)
}

see: (GitHub) Errant use of TransactionScope causes messages to be silently dropped

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.