public void PrepareTransaction(string txId) { if (TransactionalStorage.SupportsDtc == false) { throw new InvalidOperationException("DTC is not supported by " + TransactionalStorage.FriendlyName + " storage."); } using (DocumentLock.Lock()) { try { inFlightTransactionalState.Prepare(txId); Log.Debug("Prepare of tx {0} completed", txId); } catch (Exception e) { if (TransactionalStorage.HandleException(e)) { return; } throw; } } }
public void Commit(Guid txId) { try { TransactionalStorage.Batch(actions => { actions.Transactions.CompleteTransaction(txId, doc => { // doc.Etag - represent the _modified_ document etag, and we already // checked etags on previous PUT/DELETE, so we don't pass it here if (doc.Delete) { Delete(doc.Key, null, null); } else { Put(doc.Key, null, doc.Data, doc.Metadata, null); } }); actions.Attachments.DeleteAttachment("transactions/recoveryInformation/" + txId, null); workContext.ShouldNotifyAboutWork(); }); } catch (Exception e) { if (TransactionalStorage.HandleException(e)) { return; } throw; } }
public void PrepareTransaction(string txId, Guid?resourceManagerId = null, byte[] recoveryInformation = null) { using (DocumentLock.Lock()) { try { inFlightTransactionalState.Prepare(txId, resourceManagerId, recoveryInformation); Log.Debug("Prepare of tx {0} completed", txId); } catch (Exception e) { if (TransactionalStorage.HandleException(e)) { return; } throw; } } }
public void Rollback(Guid txId) { try { TransactionalStorage.Batch(actions => { actions.Transactions.RollbackTransaction(txId); actions.Attachments.DeleteAttachment("transactions/recoveryInformation/" + txId, null); workContext.ShouldNotifyAboutWork(); }); } catch (Exception e) { if (TransactionalStorage.HandleException(e)) { return; } throw; } }
public void Commit(string txId) { if (TransactionalStorage.SupportsDtc == false) { throw new InvalidOperationException("DTC is not supported by " + TransactionalStorage.FriendlyName + " storage."); } try { using (DocumentLock.Lock()) { try { inFlightTransactionalState.Commit(txId); Log.Debug("Commit of tx {0} completed", txId); workContext.ShouldNotifyAboutWork(() => "DTC transaction commited"); } finally { inFlightTransactionalState.Rollback(txId); // this is where we actually remove the tx } } } catch (Exception e) { if (TransactionalStorage.HandleException(e)) { return; } throw; } finally { workContext.HandleWorkNotifications(); } }