Alberto A. Flores

Alberto A. Flores

Sr. Software Engineer

© 2022

Dark Mode

Distributed Locks with Spring Integration

Recently, I was given an opportunity to implement a use case where the team concluded that using Enterprise Integration Patterns (EIP) would help. Our distributed environment allowed for it, and we started to have discussions using the EIP lingo. While trying to use the Splitter and Aggregator patterns, I had a chance to review the source code, and learned first hand how Spring Integration implements several of these patterns.

I recommended highly the following articles:

A summary of some design points that helped my implementation using “distributed locks”:

  • Distributed locks always have a “shelf life” (so it’s really a “lease”).
  • Expiration of a “lock” is essential.
  • Use an EIP framework that supports components that remain simple.
  • Potential need to move deployments models to a platform environment following a microservices architecture.

So keeping these in mind, Spring Integration worked well. The key objects used were LockRegistry1, LockRepository2 and MessageStore3.

Both XML and Spring POJO Configuration style worked well for managing these via Spring Profiles, and thanks to Spring Boot, keeping these simple was a breeze.

References: