DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • From Prompt to Running Microservice: ServiceBricks Step-By-Step
  • Assessment of Scalability Constraints (and Solutions): Practical Advice for Overcoming Scalability Challenges
  • The Path From APIs to Containers: How Microservices Fueled the Journey
  • What Is API-First?

Trending

  • You Don't Have to Pick One: A Hybrid Approach to Enterprise Data Refresh
  • One Database, Two Models: Building AI-Friendly Java Applications With MySQL JSON Duality Views
  • Idempotency Under Concurrency: Why Your Application Check Isn't the Last Line of Defense
  • How to Evaluate Coding Agents With Harbor Framework, Python, Docker

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Microservice Integration — SAGA Pattern

Microservice Integration — SAGA Pattern

Read on to find out more about how to integrate your microservices using the SAGA pattern — including choreography-based SAGA.

By 
Dilek Karadaş Mataracı
·
Dec. 11, 19 · Review
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
20.5K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

 




 

pattern blocks

Learn more about the SAGA pattern!
 


Since the application of Microservice architectures is expanding day to day, it is becoming much more important to ensure successful integrations between these microservices.

There are some issues to consider while designing these integration patterns:

  1. Partial error handling: MicroServices are single responsibility units but business transactions require more than one of these units. If one unit(it is called a local transaction) fails, the system must be designed to do its rollback actions(it is called compensation transaction) accordingly.
  2. Manage the situations where we need to collect data from multiple services: Microservices only have their entity data; when we need enriched data from multiple entities, we need to have proper integration principles.
  3. Testing requirements of the system design: Some patterns are more appropriate for testing purposes while some others are not.
  4. The organization (the company) structure is a key point: The Agile/Waterfall working principles of the organization is also a key point for architectural design.

You may also like: Principles for Microservices Integration

Microservice Architecture depends on the Database per Service principle. On top of that principle, there is a SAGA pattern that can be applied to ensure the integrity of distributed transactions because the Database per Service principle results in a context that we need to synchronize these databases.

SAGA Pattern depends on consecutive local transactions. It can be applied in two ways:

Choreography Based SAGA Pattern

In this method, each local transaction publishes an event when its job is done. The other local transaction that receives this event performs the appropriate behavior. The work is finished when all the local transactions are done.

Choreography based SAGA pattern

In choreography based SAGA, the process is managed by local transactions itself. This confirms the principle of intelligent endpoints and dummy communication channels.

The benefits of this method are as follows:

  1. Easy to implement.
  2. Appropriate if the number of local transactions is small.
  3. Loosely coupled endpoints.
  4. Suitable for agile organizations.

There are some drawbacks of the method:

  1.  It gets very complicated when the number of local transactions increases.
  2. Cyclic dependency may occur between services.

Orchestration Based SAGA Pattern

In this method, there is an intelligent endpoint (a separate service that performs orchestration) that coordinates the whole process. It manages which service will perform when. If one of the local transactions fails for some reason, the Orchestrator is also responsible for a rollback of the previously performed transactions.

Orchestration based SAGA Pattern

The benefits of this method are:

  1. Easy to implement.
  2. Easy to understand and maintain.
  3. Complexity is not an issue when local transactions’ count dramatically increases.

The drawbacks are:

  1. This method creates a situation that the communication channel becomes intelligent and the endpoints become a dummy.
  2. All the business logic is implemented inside the orchestrator. So the orchestrator becomes the monolith.

Which method to consider is determined by the needs of the system and the organization.


Further Reading

Microservice Architecture and Design Patterns for Microservices

microservice Integration

Opinions expressed by DZone contributors are their own.

Related

  • From Prompt to Running Microservice: ServiceBricks Step-By-Step
  • Assessment of Scalability Constraints (and Solutions): Practical Advice for Overcoming Scalability Challenges
  • The Path From APIs to Containers: How Microservices Fueled the Journey
  • What Is API-First?

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook