Interface ResponseFuture
-
- All Known Implementing Classes:
ExpectedResponseFuture
public interface ResponseFuture extends Future<Object>
For each request, the relatedResponseFutureprovides methods, to query or wait on the result.- See Also:
- EventMaid Documentation
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ObjectgetErrorResponse()Waits until the future is fulfilled and returns the error payload.ObjectgetErrorResponse(long timeout, TimeUnit unit)Waits until the future is fulfilled to return the error payload or the timeout expires.ProcessingContext<Object>getRaw()Waits until the future is fulfilled and returns theProcessingContextpayload.ProcessingContext<Object>getRaw(long timeout, TimeUnit unit)Waits until the future is fulfilled and returns theProcessingContextpayload or the timeout expires.voidthen(FollowUpAction followUpAction)Adds aFollowUpAction, that gets executed, once the Future is fulfilled.booleanwasSuccessful()Returnstrueif the future was fulfilled with an success response,falseif an exception occurred, the future was cancelled or the error payload is notnull.
-
-
-
Method Detail
-
wasSuccessful
boolean wasSuccessful()
Returnstrueif the future was fulfilled with an success response,falseif an exception occurred, the future was cancelled or the error payload is notnull.- Returns:
trueif only payload is set,falseotherwise
-
getErrorResponse
Object getErrorResponse() throws InterruptedException, ExecutionException
Waits until the future is fulfilled and returns the error payload.- Returns:
- the error payload of the message or
nullif none exists - Throws:
CancellationException- if the future was cancelledInterruptedException- if the waitingThreadis interruptedExecutionException- if the future was fulfilled with an exception
-
getErrorResponse
Object getErrorResponse(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
Waits until the future is fulfilled to return the error payload or the timeout expires.- Parameters:
timeout- the interval to waitunit- the unit of the interval- Returns:
- the error payload of the message or
nullif none exists - Throws:
CancellationException- if the future was cancelledInterruptedException- if the waitingThreadis interruptedExecutionException- if the future was fulfilled with an exceptionTimeoutException- if the timeout expired
-
getRaw
ProcessingContext<Object> getRaw() throws InterruptedException, ExecutionException
Waits until the future is fulfilled and returns theProcessingContextpayload.- Returns:
- the
ProcessingContextof the message - Throws:
CancellationException- if the future was cancelledInterruptedException- if the waitingThreadis interruptedExecutionException- if the future was fulfilled with an exception
-
getRaw
ProcessingContext<Object> getRaw(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
Waits until the future is fulfilled and returns theProcessingContextpayload or the timeout expires.- Parameters:
timeout- the interval to waitunit- the unit of the interval- Returns:
- the
ProcessingContextof the message - Throws:
CancellationException- if the future was cancelledInterruptedException- if the waitingThreadis interruptedExecutionException- if the future was fulfilled with an exceptionTimeoutException- if the timeout expired
-
then
void then(FollowUpAction followUpAction)
Adds aFollowUpAction, that gets executed, once the Future is fulfilled.- Parameters:
followUpAction- theFollowUpActionto execute- Throws:
UnsupportedOperationException- if oneFollowUpActionhas already been setCancellationException- if the future has already been cancelled
-
-