Interface RemoteInvoker
- All Known Implementing Classes:
JeroMQRemoteInvoker
public interface RemoteInvoker
Holds a connection to the remote service and dispatches
Invocation
.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
The default timeout for theRemoteInvoker
static final TimeUnit
The default time unit for theRemoteInvoker
.static final String
The maximum underlying connections to maintain.static final String
The minimum underlying connections to maintain. -
Method Summary
Modifier and TypeMethodDescriptionGets the connection address for thisRemoteInvoker
.invoke
(Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) Deprecated.invokeAsync
(Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) Sends theInvocation
to the remote service and waits for theInvocationResult
.default Void
invokeAsyncV
(Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) Sends theInvocation
to the remote service and waits for theInvocationResult
.invokeCompletionStage
(Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) Sends theInvocation
to the remote service and waits for theInvocationResult
.invokeFuture
(Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) Sends theInvocation
to the remote service and waits for theInvocationResult
.default Object
invokeSync
(Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) Sends theInvocation
to the remote service and waits for theInvocationResult
.default void
Starts thisRemoteInvoker
and connects to the supplied address.void
Starts up thin is complete.default void
stop()
Stops thisRemoteInvoker
.
-
Field Details
-
DEFAULT_TIMEOUT
static final long DEFAULT_TIMEOUTThe default timeout for theRemoteInvoker
- See Also:
-
DEFAULT_TIMEOUT_UNITS
The default time unit for theRemoteInvoker
. -
REMOTE_INVOKER_MIN_CONNECTIONS
The minimum underlying connections to maintain.- See Also:
-
REMOTE_INVOKER_MAX_CONNECTIONS
The maximum underlying connections to maintain.- See Also:
-
-
Method Details
-
getConnectAddress
String getConnectAddress()Gets the connection address for thisRemoteInvoker
. This should be the last value passed tostart(String)
orstart(String, long, TimeUnit)
.- Returns:
- the connect address
-
start
Starts thisRemoteInvoker
and connects to the supplied address.- Parameters:
connectAddress
- the connect address
-
start
Starts up thin is complete. 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. -
invoke
@Deprecated default Future<Object> invoke(Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) Deprecated.This maps directly toinvokeFuture(Invocation, List, InvocationErrorConsumer)
, but was renamed for clarity on the behavior. This is not very useful because it can force more threads than are necessary to create a remote invocation.- Parameters:
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
-
invokeAsyncV
default Void invokeAsyncV(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:
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 and ease of integration with Reflections
-
invokeAsync
AsyncOperation invokeAsync(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:
invocation
- the outgoingInvocation
asyncInvocationResultConsumerList
- aList<Consumer<InvocationResult>>
to capture all async resultsasyncInvocationErrorConsumer
- aConsumer<InvocationError>
to receive async errors- Returns:
- an instance of
AsyncOperation
-
invokeFuture
default Future<Object> invokeFuture(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:
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
-
invokeCompletionStage
CompletionStage<Object> invokeCompletionStage(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:
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
default Object invokeSync(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(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:
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
-
invokeFuture(Invocation, List, InvocationErrorConsumer)
, but was renamed for clarity on the behavior.