Interface RetryHandler<TResult>

Type Parameters:
TResult - type of the result
ServiceRegion region = System.getenv("CTP_REGION") == null ? ServiceRegion.GCP_EUROPE_WEST1
        : ServiceRegion.valueOf(System.getenv("CTP_REGION"));
String authURL = System.getenv("CTP_AUTH_URL") == null ? region.getOAuthTokenUrl()
        : System.getenv("CTP_AUTH_URL");
String apiUrl = System.getenv("CTP_API_URL") == null ? region.getApiUrl() : System.getenv("CTP_API_URL");

final ProjectApiRoot projectApiRoot = ApiRootBuilder.of()
        .defaultClient(ClientCredentials.of()
                .withClientId(CommercetoolsTestUtils.getClientId())
                .withClientSecret(CommercetoolsTestUtils.getClientSecret())
                .build(),
            authURL, apiUrl)
        .withErrorMiddleware(ErrorMiddleware.ExceptionMode.UNWRAP_COMPLETION_EXCEPTION)
        .build(CommercetoolsTestUtils.getProjectKey());

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 = RetryHandler
            .concurrentModification(projectApiRoot.carts()
                    .withId(cart.getId())
                    .post(CartUpdateBuilder.of()
                            .version(cart.getVersion())
                            .actions(CartSetCountryActionBuilder.of().country("DE").build())
                            .build()),
                CartUpdate::builder, CartUpdateBuilder::version)
            .executeBlocking()
            .getBody();
    return modCart;
});

See the test code.


public interface RetryHandler<TResult>
Handler functions to retry single requests.