Search in sources :

Example 1 with MultiplexedCallback

use of com.linkedin.restli.client.multiplexer.MultiplexedCallback in project rest.li by linkedin.

the class RestClient method sendRequest.

/**
   * Sends a multiplexed request. Responses are provided to individual requests' callbacks. After all responses are
   * received the given aggregated callback is invoked.
   *
   * The request is sent using the protocol version 2.0.
   *
   * @param multiplexedRequest  the multiplexed request to send.
   * @param requestContext context for the request
   * @param callback the aggregated response callback.
   */
public void sendRequest(MultiplexedRequest multiplexedRequest, RequestContext requestContext, Callback<MultiplexedResponse> callback) {
    MultiplexedCallback muxCallback = new MultiplexedCallback(multiplexedRequest.getCallbacks(), callback);
    addDisruptContext(MULTIPLEXER_RESOURCE, requestContext);
    try {
        RestRequest restRequest = buildMultiplexedRequest(multiplexedRequest);
        _client.restRequest(restRequest, requestContext, muxCallback);
    } catch (Exception e) {
        muxCallback.onError(e);
    }
}
Also used : RestRequest(com.linkedin.r2.message.rest.RestRequest) MultiplexedCallback(com.linkedin.restli.client.multiplexer.MultiplexedCallback) URISyntaxException(java.net.URISyntaxException) ParseException(javax.mail.internet.ParseException) IOException(java.io.IOException)

Aggregations

RestRequest (com.linkedin.r2.message.rest.RestRequest)1 MultiplexedCallback (com.linkedin.restli.client.multiplexer.MultiplexedCallback)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 ParseException (javax.mail.internet.ParseException)1