-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Outbox implementation with TransactionScope #99
Comments
Hmm curious as you made me I went through QuickWatch reflection on I then coded this little example to see if I could actually get it to work. The central bits look somewhat like this: static SqlTransaction GetSqlTransactionViaReflection(SqlConnection connection)
{
const BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
var innerConnectionField = connection.GetType().GetProperty("InnerConnection", flags);
var innerConnection = innerConnectionField?.GetValue(connection);
var availableInnerTransactionField = innerConnection?.GetType().GetProperty("AvailableInternalTransaction", flags);
var availableInnerTransaction = availableInnerTransactionField?.GetValue(innerConnection);
var parentTransactionField = availableInnerTransaction?.GetType().GetProperty("Parent", flags);
var parentTransaction = parentTransactionField?.GetValue(availableInnerTransaction) as SqlTransaction;
return parentTransaction;
} It succeeds in retrieving the I have not been able to figure out a way to retrieve the transaction in any other way. Maybe it would be a nice addition to the API to enable doing something like this: // somewhere, possibly far out in the call hierarchy
using var txScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
// further down:
using var scope = new RebusTransactionScope();
scope.UseOutboxWithAmbientTransaction();
// whee! I don't think it would be too hard to enable this, but it's hard to tell if there's a surprise or two lurking in there. |
Thanks for your work! BTW it is Cofoundry: https://www.cofoundry.org/docs/framework/data-access/transactions |
The current Outbox implementation requires both an SqlConnection as well as an SqlTransaction as shown on https://github.com/rebus-org/Rebus/wiki/Outbox :
Unfortunately I work with a framework that uses TransactionScope - and I have found no way to get the SqlTransaction out of that.
Is there any way to get SqlTransaction out of SqlConnection (I haven't found one)?
Would it be possible to expand the Outbox implementation to work with TransactionScope in addition to SqlTransaction?
The text was updated successfully, but these errors were encountered: