void IHandle <StorageMessage.WriteTransactionStart> .Handle(StorageMessage.WriteTransactionStart message) { Interlocked.Decrement(ref FlushMessagesInQueue); try { if (message.LiveUntil < DateTime.UtcNow) { return; } var record = LogRecord.TransactionBegin(Writer.Checkpoint.ReadNonFlushed(), message.CorrelationId, message.EventStreamId, message.ExpectedVersion); var res = WritePrepareWithRetry(record); // we update cache to avoid non-cached look-up on next TransactionWrite _indexWriter.UpdateTransactionInfo(res.WrittenPos, res.WrittenPos, new TransactionInfo(-1, message.EventStreamId)); } catch (Exception exc) { Log.ErrorException(exc, "Exception in writer."); throw; } finally { Flush(); } }
void IHandle <StorageMessage.WriteTransactionStart> .Handle(StorageMessage.WriteTransactionStart message) { Interlocked.Decrement(ref FlushMessagesInQueue); try { if (message.LiveUntil < DateTime.UtcNow) { return; } var logPosition = Writer.Checkpoint.ReadNonFlushed(); var record = ShouldCreateStreamFor(message) ? LogRecord.StreamCreated(logPosition, message.CorrelationId, logPosition, message.EventStreamId, LogRecord.NoData) : LogRecord.TransactionBegin(logPosition, message.CorrelationId, message.EventStreamId, message.ExpectedVersion); WritePrepareWithRetry(record); } finally { Flush(); } }