The use case here is I have to register students for a course . The input to this lambda will be student ID and Course ID. It involves following steps.
- call API 1 to get Student info
- call API 2 to get Course info
- Store Student details first in API 3 and get unique ID
- Save the ID and status as "Student_Registered" in DB (UI will keep checking status of registration process)
- Store StudentCourse details in API 3 with the unique ID generated in step 3 .
- Save the Registed object with status "Registration Completed" in DB
In this cases there might be possibility to have failure happens
- delay / exception from API 1
- delay / exception from API 2
- delay / exception from API 3 while storing Student
- exception from API 3 while storing Course (Note Student is registered and StudentCourse is failed )
- Save in DB may fail
My thoughts on this is to update DB after every step so that if At any point exception occurs I should be able to retry from the step it failed . What would be the efficient/best way to implement this. I read about step function would be the best way to handle this . Need suggestion from experienced people.Any examples / reference would also help.
