Question
5
Replies
117
Views
Asurion
Posted: January 2, 2020
Last activity: January 3, 2020
Closed
REST Services - Transaction Rollback
Hi
I have a scenario where my pega flow makes three REST calls (C1, C2 and C3) sequentially to three different external systems to complete a business transaction. All these are POST operations and makes some changes in their respective systems. If C3 fails, I want changes occurred within C1 and C2 should be rolled back. Is there a standard design approach for this? Please advise.
Since REST is stateless by design, there is no way to roll back a transaction. A possible way is to create certain endpoints/methods designated to validating a request. Let's say that you want to call UploadDocument -- there could be a ValidateUploadDocument. If the latter returns anything else than 200, you just won't call the former.
In your case:
Naturally, this could require changing your services in the first place. Another potentially less elegant way is to use DELETE for C1 and C2 if C3 fails (if DELETE methods are available).