Fork me on GitHub

Concurrency control using ETags Edit on GitHub


Pomona supports optimistic concurrency control by using a combination of ETags and the If-Match header.

For this to work we need to specify what property to use as the ETag.


        public void Map(ITypeMappingConfigurator<EtaggedEntity> map)
        {
            map.Include(x => x.ETag, o => o.AsEtag());
        }

Every time a PATCH request is made to this resource with the If-Match header set to the previously seen ETag header it will compare the header value with the current ETag value. If the ETag has changed Pomona will abort the request with a 412 Precondition Failed status code.

When using a data layer with optimistic concurrency control we should also throw a ResourcePreconditionFailedException if a conflict is detected during update.