In this code:
var trans = _connection.StartTransactionAsync(StreamName, seqNumber).Result;
try
{
trans.WriteAsync(evtData).Wait();
trans.CommitAsync().Wait();
}
catch
{
trans.Rollback();
throw;
}
I might get a WrongExpectedVersionException.
My expectation would be that this Exception would be thrown at the WriteAsync(…).Wait() call allowing me to call Rollback in the catch block.
But contrary to my expectations the exception is thrown at CommitAsync().Wait() - and when I then call Rollback I get a new exception telling me that the transaction is already committed ?!
This is not true because the event does not arrive at the stream.
First of all it is weird that the transaction is registered as committed, secondly what is the use of Rollback in the above. It can never be called in the above code, because Write will never fail, only commit and commit disallows Rollback,
So what is the correct use of transactions ? The documentation does not tell me. It only gives me the method names and parameters.
There is also a method called ContinueTransaction which is a total mystery to me I expect there is something I am missing - a simple code sample might help.
Regards Jesper