Important Usage Tips¶
Customized ProjectApiRoot
Creation¶
When creating a customized ProjectApiRoot
the following remarks should be considered:
-
Limit the number of concurrent requests done to CTP. This can be done by adding a QueueMiddleware to the ApiRootBuilder QueueMiddleware
-
Retry on 5xx errors with a retry strategy. This can be achieved by adding a RetryRequestMiddleware to the ApiRootBuilder RetryRequestMiddleware
If you have no special requirements on the client creation, then you can use the ClientConfigurationUtils#createClient
util which applies the best practices for ProjectApiRoot
creation.
To understand how to initialize those method arguments, please refer to the unit test
To tune / customize your client please refer to Client Tuning
Tuning the Sync Process¶
The sync library is not meant to be executed in a parallel fashion. For example:
final ProductSync productSync = new ProductSync(syncOptions);
final CompletableFuture<ProductSyncStatistics> syncFuture1 = productSync.sync(batch1).toCompletableFuture();
final CompletableFuture<ProductSyncStatistics> syncFuture2 = productSync.sync(batch2).toCompletableFuture();
CompletableFuture.allOf(syncFuture1, syncFuture2).join;
final ProductSync productSync = new ProductSync(syncOptions);
productSync.sync(batch1)
.thenCompose(result -> productSync.sync(batch2))
.toCompletableFuture()
.join();
- Changing the number of max parallel requests within the
projectApiRoot
configuration. It defines how many requests the client can execute in parallel. - or changing the draft batch size. It defines how many drafts can one batch contains.
The current overridable default configuration of the projectApiRoot
is the recommended good balance for stability and performance for the sync process.
In order to exploit the number of max parallel requests
, the batch size
should have a value set that is equal or higher.