I have a consumer where I begin a serializable transaction.
public class Consumer : IConsumer<Message>
{
public async Task Consume(ConsumeContext<Message> context)
{
using var transaction = dbContext.Database.BeginTransaction(System.Data.IsolationLevel.Serializable);
// Do Something
transaction.Commit();
}
}
I'm trying to use the new MassTransit Transactional Outbox, but with the outbox configured I can't open this inside transaction because all consumers become wrapped in a transaction and it doesn't allow nested transactions.
One way that I see to solve this is changing the outbox transaction isolation level to serializable so I don't need to open this one inside the consumer, but I don't want to change the isolation level on all my outbox consumers.
Is there a way to configure the outbox transaction isolation level per consumer?
If not, is there another way I could to solve this?
I figured out how to change the isolation level for all the outbox consumers, but didn't find how to change it individually.