Interface ConcurrentModificationMiddleware

All Superinterfaces:
Middleware

public interface ConcurrentModificationMiddleware extends Middleware
Middleware to retry a request upon ConcurrentModificationException
String projectKey = CommercetoolsTestUtils.getProjectKey();

ProjectApiRoot projectApiRoot = ApiRootBuilder.of()
        .defaultClient(ClientCredentials.of()
                .withClientId(CommercetoolsTestUtils.getClientId())
                .withClientSecret(CommercetoolsTestUtils.getClientSecret())
                .build(),
            ServiceRegion.GCP_EUROPE_WEST1)
        .addConcurrentModificationMiddleware(3)
        .build(projectKey);

CartsFixtures.withUpdateableCart(cart -> {

    final ApiHttpResponse<Cart> deCart = projectApiRoot.carts()
            .withId(cart.getId())
            .post(CartUpdateBuilder.of()
                    .version(cart.getVersion())
                    .actions(CartSetCountryActionBuilder.of().country("DE").build())
                    .build())
            .executeBlocking();

    final Cart modCart = projectApiRoot.carts()
            .withId(cart.getId())
            .post(CartUpdateBuilder.of()
                    .version(cart.getVersion())
                    .actions(CartSetCountryActionBuilder.of().country("DE").build())
                    .build())
            .executeBlocking()
            .getBody();
    return modCart;
});

See the test code.