1

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

Important note: in our case we don't need a compensation mechanism to revert the operations.

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

HK15
  • 47
  • 9

1 Answers1

1

Sure, here's a concise version:

The SAGA pattern can be beneficial in your scenario:

  1. SAGA with REST APIs:

    • Can be used if services are visible to each other.
    • Offers centralized control but might create tight coupling and lacks automatic retry policies.
  2. SAGA with an Event Bus:

    • Promotes loose coupling, scalability, and resilience.
    • Allows use of features like retries and parallel processing.
    • Scatters logic across services, making it harder to manage.
  3. Handling Failure:

    • Even if you don't need a compensation mechanism, handling failures is crucial in SAGA for maintaining data consistency.

Choosing between REST APIs, an event bus, or a combination depends on your system's complexity and requirements.

Ahmeric
  • 46
  • 3