Does Hangfire.Pro.Redis Participate in .NET TransactionScope?

Hi,

We use Hangfire with SQL Server but are considering paying for Hangfire.Pro.Redis.

Currently, we sometimes open a .NET TransactionScope around database operations and Hangfire enqueues. If the transaction is rolled back, this also rolls back the Hangfire database operations.

As we consider paying for Hangfire.Pro.Redis, I’m interested to know if Hangfire with Redis participates in transaction scopes created outside the call to queue a Hangfire job. Specifically, if a TransactionScope rolls back, will it also roll back the Redis operations performed by Hangfire?

If not, are there any suggested workarounds to prevent the Hangfire job from running or continuing if the TransactionScope at the time of enqueuing rolls back?

Thanks!

Hello

When using Hangfire with Redis, it doesn’t directly participate in .NET TransactionScopes. If you want to ensure that Hangfire jobs are rolled back along with your SQL transactions, you’ll need a custom solution like managing transactions explicitly, developing custom middleware, using distributed transactions, or designing idempotent jobs. Each approach has its pros and cons, so choose based on your specific needs and constraints.

Hope it helps !

Thank you
nathaniel

Thanks Nathaniel

That’s what I feared, I’ll consider your suggested solutions.