Loading

Optimistic locking in B2C Commerce

Дата публикации: Apr 29, 2025
Описание

Information on how optimistic locking works in the B2C Commerce platform.

Решение

The use of Optimistic Locking is a design decision made by B2C Commerce which aims to account for business logic that updates objects. The goal is that since objects can be concurrently updated by different threads / processes, the platform should be designed to cope with that. Therefore, an OptimisticLockingException error is not an error condition in the strictest sense, but rather an expected behavior for object updates since there can be multiple threads updating an object at any given time. It's reasonable to assume that you will encounter situations where an object you are working with has been updated during the time that you are updating it.

Some suggestions we can provide to account for this are below:

  • Since there are several ways an object could get updated (the customer could change it, a customer service representative could change something, another job or script, etc.), you could put in custom logging around the events that change the object. This will give you have an understanding as to when and who/what is altering the object at least, and then you can make code design changes based on what your typical behavior is, what your business tolerances are, etc.
  • You can also explore the various APIs (Script, OCAPI & SCAPI) for more ideas on the subject of handling the object's state.
  • Make use of B2C Community. Developers are usually very good at sharing their ideas, especially if their ideas help other customers.
Номер статьи базы знаний

000391455

 
Загрузка
Salesforce Help | Article