I am trying to solve a problem where a lot of transactions happening in the business logic.
For example:
The request comes to the server (Service A)
- Step 1 - Transaction in DB
- Step 2 - Call Service B
- Step 3 - Another transaction to DB
- Step 4 - Call Service C
- Step 5 - 3rd Party service call
- Step 6 - Another transaction to DB
and so on... all the steps are dependent on the previous step.
Now, the problem is, if a step failed, I don't want to roll back the whole transaction but want to start from where it failed.
Is there a design pattern/solution that exists or what is the best way to solve this problem?
One of the solutions in my mind is
Break down the whole business logic into smaller logic (Per step) once a Step is complete, it will push the message in Queue (another Topic - Step2) and so on. If any of the steps failed, that will be picked from the queue again. This will solve the problem of retrying from the step it failed but I am worried about resources. Per call, I have to push around 7-8 messages (Steps) in the queue and process them separately.
Aucun commentaire:
Enregistrer un commentaire