Writeconflict_Transactions_Management
These processes when run concurrently demonstrate how to retry a transaction in case of a writeconflict exception. UpdateDocument, QueryDocument and RemoveDocument activities are placed inside transaction group surrounded by RepeatonError group. RepeatonError group repeats for the number of retrials configured only in the case of a writeconflict exception. The RepeatonError group terminates for any other exceptions. WriteConflict exception occurs when both the processes run at the same time. If there is a writeconflict exception in a transaction, the transaction waits for two seconds before retrial for the concurrent transaction to release the write lock. The transaction keeps retrying until the retrial count configured value reaches or no writeconflict exception is encountered.
Activity | Description |
---|---|
CleanDocuments | Removes all the documents in the specified collection. |
InsertDocument | Inserts a document in the specified collection that is used by activities inside local transaction group. Specified collection is created if it does not exist. This activity is used because transactions work only on existing collections. |
UpdateDocument | This is the first activity inside a transaction. Transaction starts with a session that is used for subsequent activities inside group. Updates the inserted document with a field in the specified collection using the session. |
QueryDocument | Queries the inserted document in the specified collection using the session. |
RemoveDocument | Removes the document inserted in the specified collection using the session. |
ErrorCondition | Error transition is created from transaction group. If the exception is writeconflict redirecting to WriteConflictSleep activity and for other types of exceptions or when the retrial count exceeds for writeconflict exceptions terminating RepeatonError using condition expressions. |
WriteConflictSleep | Makes the transaction to wait for the specified time interval. |