Interface RemoteInvocationDispatcher
- All Known Implementing Classes:
SimpleRemoteInvocationDispatcher
public interface RemoteInvocationDispatcher
-
Method Summary
Modifier and TypeMethodDescriptioninvokeAsync
(Route route, Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) Sends theInvocation
to the remote service and waits for theInvocationResult
.default Void
invokeAsyncV
(Route route, Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) InvokesinvokeAsyncV(Route, Invocation, List, InvocationErrorConsumer)
, ignoring the returnedAsyncOperation
.invokeFuture
(Route route, Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) Sends theInvocation
to the remote service and waits for theInvocationResult
.invokeSync
(Route route, Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) Sends theInvocation
to the remote service and waits for theInvocationResult
.default void
start()
Starts up this dispatcher.default void
stop()
Stops thisRemoteInvoker
.
-
Method Details
-
start
default void start()Starts up this dispatcher. The default implementation of this method does nothing in case no setup is necessary. -
stop
default void stop()Stops thisRemoteInvoker
. This method must gracefully shut down all connections and stop any worker threads. THe default implementation of this method does nothing in case no shutdown is necessary. -
invokeAsyncV
default Void invokeAsyncV(Route route, Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) InvokesinvokeAsyncV(Route, Invocation, List, InvocationErrorConsumer)
, ignoring the returnedAsyncOperation
. -
invokeAsync
AsyncOperation invokeAsync(Route route, Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) Sends theInvocation
to the remote service and waits for theInvocationResult
. The suppliedConsumer<InvocationError>
will relay all encountered errors. Typically this is used with theDispatch.Type.ASYNCHRONOUS
. This returns the generic Void type to clarify the intention of the method that the underlyingFuture
is discarded, but since is is intended to be used with reflections code, this allows for the method to be easily adapted as such.- Parameters:
route
- theRoute
through which to send theInvocation
invocation
- the outgoingInvocation
asyncInvocationResultConsumerList
- aList<Consumer<InvocationResult>>
to capture all async resultsasyncInvocationErrorConsumer
- aConsumer<InvocationError>
to receive async errors- Returns:
- a null
Void
, for the sake of clarity
-
invokeFuture
Future<Object> invokeFuture(Route route, Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) Sends theInvocation
to the remote service and waits for theInvocationResult
. The suppliedConsumer<InvocationError>
will relay all encountered errors. Typically this is used with theDispatch.Type.FUTURE
- Parameters:
route
- theRoute
through which to send theInvocation
invocation
- the outgoingInvocation
asyncInvocationResultConsumerList
- aList<Consumer<InvocationResult>>
to capture all async resultsasyncInvocationErrorConsumer
- aConsumer<InvocationError>
to receive async errors- Returns:
- a
Future<Object>
which returns the result of the remote invocation
-
invokeSync
Object invokeSync(Route route, Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) throws Exception Sends theInvocation
to the remote service and waits for theInvocationResult
. The suppliedConsumer<InvocationError>
will relay all encountered errors. Typically this is used with theDispatch.Type.SYNCHRONOUS
The default implementation of this method simply uses theFuture<Object>
returned by the method defined byinvokeFuture(Route, Invocation, List, InvocationErrorConsumer)
and blocks onFuture.get()
. However, the underlying implementation should override this method to implement a more efficient means of blocking, such as actually blocking on the underlying network socket.- Parameters:
route
- theRoute
through which to send theInvocation
invocation
- the outgoingInvocation
asyncInvocationResultConsumerList
- aList<Consumer<InvocationResult>>
to capture all async resultsasyncInvocationErrorConsumer
- aConsumer<InvocationError>
to receive async errors- Returns:
- the result of the remote
Invocation
- Throws:
Exception
-