DevOps Articles

Curated articles, resources, tips and trends from the DevOps World.

Concurrency Control In REST API With Spring Framework

5 years ago dzone.com
Concurrency Control In REST API With Spring Framework

Summary: This is a summary of an article originally published by the source. Read the full original article here →

We generally want to avoid situations when changes made by one client are overridden by another one without even knowing. In order to prevent our data integrity from being violated we often use locking mechanisms provided by our database engine, or even use abstractions provided by tools like JPA.

One of the business rules we discovered and described in previous section is that a book can be placed on hold if and only if it is available.

Well, if we want to protect ourselves from so-called lost updates what we need to do while persisting the state of our aggregate is to check if the aggregate we want to update hasn’t been changed by someone else in the meantime.

The reason behind it is that in the context of REST controller we do not (and should not) care about how this attribute is calculated and updated – the fact that it changes is enough information.

Made with pure grit © 2024 Jetpack Labs Inc. All rights reserved. www.jetpacklabs.com