Package com.azure.android.core.http
Class HttpCallDispatcher
- java.lang.Object
 - 
- com.azure.android.core.http.HttpCallDispatcher
 
 
- 
public final class HttpCallDispatcher extends java.lang.ObjectThe dispatcher to dispatch async HTTP calls send through the pipeline. Additionally, an HttpClient that does not have native async support can also use the dispatcher to enable async HTTP calls. 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceHttpCallDispatcher.HttpCallFunctionContract representing an HTTP call to execute. 
- 
Constructor Summary
Constructors Constructor Description HttpCallDispatcher()Creates an HttpCallDispatcher with an ExecutorService with default settings to execute HTTP calls.HttpCallDispatcher(java.util.concurrent.ExecutorService executorService)Creates an HttpCallDispatcher that uses the givenexecutorServiceto execute HTTP calls.HttpCallDispatcher(java.util.concurrent.ExecutorService executorService, java.util.concurrent.ScheduledExecutorService scheduledExecutorService)Creates an HttpCallDispatcher that uses the givenexecutorServiceto execute HTTP calls and uses the the givenscheduledExecutorServiceto schedule HTTP calls to execute onexecutorServiceafter a specific delay. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidenqueue(HttpCallDispatcher.HttpCallFunction httpCallFunction, HttpRequest httpRequest, com.azure.android.core.util.CancellationToken cancellationToken, HttpCallback httpCallback)Enqueue a function to perform the HTTP call on the dispatcher thread.intgetMaxRunningCalls()Gets the maximum number of HTTP calls that can run concurrently in the dispatcher threads.voidsetMaxRunningCalls(int maxCalls)Sets the maximum number of HTTP calls to run concurrently. 
 - 
 
- 
- 
Constructor Detail
- 
HttpCallDispatcher
public HttpCallDispatcher()
Creates an HttpCallDispatcher with an ExecutorService with default settings to execute HTTP calls. 
- 
HttpCallDispatcher
public HttpCallDispatcher(java.util.concurrent.ExecutorService executorService)
Creates an HttpCallDispatcher that uses the givenexecutorServiceto execute HTTP calls.- Parameters:
 executorService- The executor service.
 
- 
HttpCallDispatcher
public HttpCallDispatcher(java.util.concurrent.ExecutorService executorService, java.util.concurrent.ScheduledExecutorService scheduledExecutorService)Creates an HttpCallDispatcher that uses the givenexecutorServiceto execute HTTP calls and uses the the givenscheduledExecutorServiceto schedule HTTP calls to execute onexecutorServiceafter a specific delay.- Parameters:
 executorService- The executor service.scheduledExecutorService- The scheduled executor service.
 
 - 
 
- 
Method Detail
- 
setMaxRunningCalls
public void setMaxRunningCalls(int maxCalls)
Sets the maximum number of HTTP calls to run concurrently.Calls beyond this value will be stored in-memory queue waiting for running calls to complete.
- Parameters:
 maxCalls- The maximum number of HTTP calls to run concurrently.- Throws:
 java.lang.IllegalArgumentException- if value ofmaxCallsparameter is less than 1.
 
- 
getMaxRunningCalls
public int getMaxRunningCalls()
Gets the maximum number of HTTP calls that can run concurrently in the dispatcher threads.- Returns:
 - The maximum number of HTTP calls that can run concurrently.
 
 
- 
enqueue
public void enqueue(HttpCallDispatcher.HttpCallFunction httpCallFunction, HttpRequest httpRequest, com.azure.android.core.util.CancellationToken cancellationToken, HttpCallback httpCallback)
Enqueue a function to perform the HTTP call on the dispatcher thread.- Parameters:
 httpCallFunction- The function that perform the HTTP call when invoked.httpRequest- The HTTP request to be given tohttpCallFunctionwhen the function is invoked.cancellationToken- The cancellation token for dispatcher to check whether the function is cancelled.httpCallback- The HTTP callback to be given tohttpCallFunctionto notify the result of the HTTP call.
 
 - 
 
 -