public class RequestBundler extends Object
Constructor and Description |
---|
RequestBundler(BroadWorksServer broadWorksServer)
Creates a new RequestBundler for the given BroadWorksServer
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected Future<ResponseBundle> |
fire()
Fires the RequestBundler.
|
org.apache.commons.lang3.mutable.MutableInt |
getOutstandingBundleCount() |
ExecutorService |
getResponseService() |
<R extends Response> |
postResponse(Request<R> request,
ResponseBundle responseBundle)
Posts the response from the response bundle to the mapped request.
|
<R extends Response> |
put(Request<R> request,
Consumer<R> consumer)
Adds a Request to the RequestBundler to be completed in the next outgoing bundle.
|
<R extends Response> |
putAndWait(List<? extends Request<R>> requests,
Consumer<R> consumer)
Adds a list of Requests to the RequestBundler and waits until the Requests have been completed to return.
|
<R extends Response> |
putAndWait(Request<R> request,
Consumer<R> consumer)
Adds a Request to the RequestBundler and waits until the Request has been completed to return.
|
void |
waitForEmptyQueue()
Method to Block for up to the AsyncLoadTimeout for the current request queue to clear
|
public RequestBundler(BroadWorksServer broadWorksServer)
broadWorksServer
- The BroadWorksServer for this Bundlerpublic ExecutorService getResponseService()
public org.apache.commons.lang3.mutable.MutableInt getOutstandingBundleCount()
public void close()
protected Future<ResponseBundle> fire()
public <R extends Response> void postResponse(Request<R> request, ResponseBundle responseBundle)
If the ResponseBundle is null -- due to a socket timeout for exampe - the request is removed from the map but the consumer is not fired.
R
- The response type.request
- The request to retrieve a response from the bundle.responseBundle
- The response bundle for the request bundle.public <R extends Response> Future<ResponseBundle> put(Request<R> request, Consumer<R> consumer)
If the request is null or invalid it will not be added to the backing bundle. A null consumer is allowed but the response will be ignored.
R
- The Response typerequest
- The request to sendconsumer
- The consumer of the responsepublic <R extends Response> boolean putAndWait(Request<R> request, Consumer<R> consumer)
R
- The Response typerequest
- The request to sendconsumer
- The consumer of the responsepublic <R extends Response> boolean putAndWait(List<? extends Request<R>> requests, Consumer<R> consumer)
R
- The Response typerequests
- The requests to sendconsumer
- The consumer of the responsepublic void waitForEmptyQueue()
Copyright © 2016 ECG. All rights reserved.