mercredi 3 mai 2023

SAGA Pattern in a macro-services Spring Boot Web application

I'm trying to understand what could be the best solution to manage a Web application in Spring Boot made of "Macro-services" and if the SAGA Pattern (Orchestrator) can be adequate in this context with or without the use of an Event Bus .

I try to describe the scenario we have:

N "Macro-services" where each is a particular workflow to manage the onboarding - unboarding of users in a system made up of different databases.

Flow A (Onboarding utente) Spring Boot App A

Step 1

  1. Filling in a form
  2. Data entry on a MongoDB database
  3. Entering data into a MySQL database
  4. Entering data on Active Directory
  5. Create an account on Salesforce
  6. Sending an email with a link to user X

Step 2

  1. User X receives the email with a link
  2. Click on the link that leads to a form
  3. Compilation of the form
  4. Data update on MongoDB
  5. Data update on MySQL

Flow B (Unboarding utente) Spring Boot App B

  • Conceptually similar to flow A but with reverse operations regarding data entry and updating.

Currently Flow A and B are two separate applications built with Spring Boot and share the code for the "Repository Layer" (external Lib in a multi-module Maven application) when there is a need to write/read from databases (MongoDB, MySQL, ActiveDirectory etc.)

The order of operations within the single flow is important and should be able to have a mechanism to manage the restart of the flow from its point of interruption.

Example without errors: Writing to MongoDB => Writing to MySQL => Writing to Active Directory => Salesforce API call => Sending email

Example with errors:

Writing to MongoDB => Writing to MySQL => Failure Writing to Active Directory => Error log

Manual Flow Restart:

Skip Writing to MongoDB => Skip Writing to MySQL => Writing to Active Directory => Salesforce API Call => Sending Email

As I indicated above we don't have separate micro-services that communicate via an Event Bus but several monolithic applications each dedicated to a distinct application flow that affects different databases (and not only).

Is it possible/recommended to use the SAGA pattern (Orchestrator) with REST APIs instead of an Event bus in this case?

Advantages and disadvantages?

If we wish we could still use an Event bus since we are working on AWS.

Thanks

Aucun commentaire:

Enregistrer un commentaire