Commercetools
Beginner
Resources, Versions, and Update Actions
Work with Commercetools optimistic locking, update actions, query predicates, and idempotent integration behavior.
40 min
3 sections
resources
versions
update-actions
1
2
3
01. Respect optimistic locking
Section 1 of 3
Most mutable resources include a version. Updates provide the current version and a list of update actions. If another process changed the resource first, the caller receives a concurrent modification response and must reload, merge, and retry only when the business operation is still valid.
text
Update flow:
1. Read Cart cart-123 at version 17.
2. Build update actions from the desired business change.
3. POST update with version 17.
4. If successful, receive Cart version 18.
5. If concurrent modification occurs, reload latest Cart.
6. Re-evaluate the business operation before retrying.Back to Course