Asynchronous Requests (Java)


One benefit of server-side integration is that you can leverage the huge bandwidth and computing resources available on the server-side by using parallelism. Target Java SDK supports asynchronous requests, which can reduce the effective target time to zero.

Supported Methods


CompletableFuture<TargetDeliveryResponse> getOffersAsync(TargetDeliveryRequest request);
CompletableFuture<ResponseStatus> sendNotificationsAsync(TargetDeliveryRequest request);
CompletableFuture<Attributes> getAttributesAsync(TargetDeliveryRequest targetRequest, String ...mboxes);


A sample Spring application Controller could look like this:

Sample Controller

public class TargetRestController {

    private TargetClient targetJavaClient;

        public TargetDeliveryResponse mboxTargetOnlyAsync(
                @RequestParam(name = "mbox", defaultValue = "server-side-mbox") String mbox,
                HttpServletRequest request, HttpServletResponse response) {
            ExecuteRequest executeRequest = new ExecuteRequest()

            TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder()
            CompletableFuture<TargetDeliveryResponse> targetResponseAsync =
            targetResponseAsync.thenAccept(tr -> setCookies(tr.getCookies(), response));
            TargetDeliveryResponse targetResponse = targetResponseAsync.join();
            return targetResponse;

     * Function for simulating network calls like other microservices and database calls
    private void simulateIO() {
        try {
        } catch (InterruptedException e) {


This example assumes you have initialized the SDK as a spring bean and that you have utility methods available.

The Target request is fired before simulateIO and by the time it is executed target result should also be ready. Even if it is not, you will have significant savings in most cases.

On this page