I have the following use case in my microservices
User Experience: A contact details popup asking the user to confirm the contact details, email address & other relevant details on the UI. Once the user submits the data - The user should see contact details saved successfully/failed message on the screen.
Whenever contact details are updated, a unique comment should also be added in the background.
The downstream system exposes a couple of CRUD API endpoints for creating, retrieving, updating & deleting the contact details and the similar CRUD API endpoints for comments.
As each of these API endpoints is independent. I'm thinking of going down the route of implementing SAGA's (Choregraphy/Orchestration) with events to ensure atomicity.
A REST API endpoint(Spring Boot) on my side captures all the data modified by the user from UI as JSON and publishes an event Update_Contact_Details to a Kafka message topic.
Update_Contact_Details Consumer will read the message from the topic, call the downstream update contact details API, and write back either Contact_Details_Updated/Contact_Details_Update_Failed events.
In the happy path scenario : The Contact_Details_Updated Message will be read by Comments Listener and makes a call to downstream API to add a comment.
In the failure Scenario: The Contact_Details_Update_Failed will be read by the Contacts Detailed Failed Listener and makes a call to the Delete Contact Details API.
In either case, as the first capture from UI to API endpoint is REST API - How do I send back the success/failed responses to clients(web/mobile) as the whole process related to orchestrating the above-mentioned flow is asynchronous.