DocumentDb is written to notepad
I am trying to use DocumentDb record as part of a transaction as shown below -
using (var scope = new TransactionScope)
{
//first transaction
//write to document db
//third transaction
}
I noticed that if the third transaction fails, the documentDb write is not rolled back and I can still see the document in the collection. The first transaction (NEventStore in this case) goes back fine. Does anyone know if DocumentDb supports TrnasactionScope. What if I have a nested transaction?
Thank!
Edit: It looks like TransactionScope is not supported by DocumentDb and it doesn't know anything about them. Is there a way to make DocumentDb transactions part of an external transaction from C #? Has anyone come across this use case before?
Edit 2: Follow-up question and answer here as suggested
source to share
DocumentDB operations are independent of TransactionScope
. As soon as the operation returns, it will be performed. The database service knows nothing about TransactionScope
and has nothing to do with it.
DocumentDB has its own transaction scope when working with server-side stored procedures. You can have multiple database queries in a stored procedure, and if all is successful, an implicit commit will occur when the stored procedure ends. If something goes wrong and an exception is thrown, an implicit rollback is performed for all operations performed on the database in the scope of the stored procedure.
source to share
Many SQL users do not understand what to do when transactions are not available.
You must implement the compensation logic yourself or use frameworks such as Windows Workflow Foundation. The compensation logic is associated with enterprise integration patterns. You can also use the correlation ID pattern to check if a large operation has been performed.
SQL users handle large transactions the same way when a long-running transaction needs to be committed. https://www.amazon.com/Enterprise-Integration-Patterns-Designing-Deploying/dp/0321200683/ref=sr_1_1?ie=UTF8&qid= 1480917322 & cn = 8-1 & keywords = integration + templates
source to share