Class ExpectedResponseFuture
- java.lang.Object
-
- de.quantummaid.eventmaid.messagefunction.internal.ExpectedResponseFuture
-
- All Implemented Interfaces:
ResponseFuture,Future<Object>
public final class ExpectedResponseFuture extends Object implements ResponseFuture
-
-
Constructor Summary
Constructors Constructor Description ExpectedResponseFuture()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancancel(boolean mayInterruptIfRunning)static ExpectedResponseFutureexpectedResponseFuture(SubscriptionContainer subscriptionContainer)voidfullFill(ProcessingContext<Object> response)voidfullFillWithException(Exception e)Objectget()Objectget(long timeout, TimeUnit unit)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.booleanisCancelled()booleanisDone()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
-
expectedResponseFuture
public static ExpectedResponseFuture expectedResponseFuture(SubscriptionContainer subscriptionContainer)
-
fullFill
public void fullFill(ProcessingContext<Object> response)
-
fullFillWithException
public void fullFillWithException(Exception e)
-
wasSuccessful
public boolean wasSuccessful()
Description copied from interface:ResponseFutureReturnstrueif the future was fulfilled with an success response,falseif an exception occurred, the future was cancelled or the error payload is notnull.- Specified by:
wasSuccessfulin interfaceResponseFuture- Returns:
trueif only payload is set,falseotherwise
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfaceFuture<Object>
-
get
public Object get() throws InterruptedException, ExecutionException
- Specified by:
getin interfaceFuture<Object>- Throws:
InterruptedExceptionExecutionException
-
get
public Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
- Specified by:
getin interfaceFuture<Object>- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
getErrorResponse
public Object getErrorResponse() throws InterruptedException, ExecutionException
Description copied from interface:ResponseFutureWaits until the future is fulfilled and returns the error payload.- Specified by:
getErrorResponsein interfaceResponseFuture- Returns:
- the error payload of the message or
nullif none exists - Throws:
InterruptedException- if the waitingThreadis interruptedExecutionException- if the future was fulfilled with an exception
-
getErrorResponse
public Object getErrorResponse(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
Description copied from interface:ResponseFutureWaits until the future is fulfilled to return the error payload or the timeout expires.- Specified by:
getErrorResponsein interfaceResponseFuture- Parameters:
timeout- the interval to waitunit- the unit of the interval- Returns:
- the error payload of the message or
nullif none exists - Throws:
InterruptedException- if the waitingThreadis interruptedExecutionException- if the future was fulfilled with an exceptionTimeoutException- if the timeout expired
-
getRaw
public ProcessingContext<Object> getRaw() throws InterruptedException, ExecutionException
Description copied from interface:ResponseFutureWaits until the future is fulfilled and returns theProcessingContextpayload.- Specified by:
getRawin interfaceResponseFuture- Returns:
- the
ProcessingContextof the message - Throws:
InterruptedException- if the waitingThreadis interruptedExecutionException- if the future was fulfilled with an exception
-
getRaw
public ProcessingContext<Object> getRaw(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
Description copied from interface:ResponseFutureWaits until the future is fulfilled and returns theProcessingContextpayload or the timeout expires.- Specified by:
getRawin interfaceResponseFuture- Parameters:
timeout- the interval to waitunit- the unit of the interval- Returns:
- the
ProcessingContextof the message - Throws:
InterruptedException- if the waitingThreadis interruptedExecutionException- if the future was fulfilled with an exceptionTimeoutException- if the timeout expired
-
then
public void then(FollowUpAction followUpAction)
Description copied from interface:ResponseFutureAdds aFollowUpAction, that gets executed, once the Future is fulfilled.- Specified by:
thenin interfaceResponseFuture- Parameters:
followUpAction- theFollowUpActionto execute
-
-