Why does the object implementing IEnlistmentNotification and forcing rollback in Prepare callback doesn't get notify to Rollback ? (my question may seem confusing, so here's a exemple)
Suppose class A implements IEnlistmentNotification and if "Value" is odd, then it forces rollback in the Prepare callback.
A a1 = null;
A a2 = null;
using (TransactionScope tx = new TransactionScope())
a1 = new A();
a2 = new A();
If we run the program, the result will be :
a1 will call Prepared(); // because 2 is even
a2 will call ForceRollback(); // because 3 is odd
a1 will call Rollback(); // because it gets notified to do so
the transaction fails with a ThreadAbordException
a1 has rollback
a2 hasn't rollback // lost of integretiy !!!!
Why doesn't a2 get notified to Rollback ? If a2 forced rollback, for sure it means he wants to get notified ! It's asking to rollback !
The problem is that in this situation, a1 has rollback but not a2, so there is a lost of integrity.
Can someone help me please figure out how it's suppose to work !?