Given a transaction-aware binding with transaction flow enabled and an operation Op1 that has TransactionFlowOption.Allowed, is it possible to make a different operation Op2 invoked from operation Op1 not participate in the transaction such that whatever operation Op2 does never rolls back in case something fails in operation Op1
Illustration
// Op1: LogOnUser
OperationBehavior(TransactionScopeRequired = true)]
public bool LogOnUser(String username, String password)
{
// AuditWriteProxy declaration and instantiation
var valid = false;
/* Validation logic */
// If validation failed
if(!valid)
{
// Invoke an op in an Audit Service.
// Op2 = AuditService.Write
// **MUST NOT BE ROLLED BACK EVEN AFTER WE [throw]**
AuditServiceProxy.Write("Authentication failed for user " + username);
throw new FaultException<AuthenticationFault>("Validation failed");
// After throw, we expect everything transactional to rollback
}
AuditServiceProxy.Write("User " + username + " authenticated successfully");
return true;
}
Notes:
- The AuditService.Write operation uses msmq binding and is one-way
- I tried TransactionFlowOption.NotAllowed on the the AuditService.Write operation contract as well TransactionScopeRequired=false on the implementation.
You can use
TransactionScopeOption.Suppressin aTransactionScope:or place this suppression code into a
NonTransactionalLoggingServicemethod call