Class DefaultRoutingStrategy
java.lang.Object
dev.getelements.elements.rt.routing.DefaultRoutingStrategy
- All Implemented Interfaces:
RoutingStrategy
The default
RoutingStrategy
which simply selects a RemoteInvoker
from the
RemoteInvokerRegistry
using RemoteInvokerRegistry.getBestRemoteInvoker(ApplicationId)
and sends the
Invocation
there.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioninvokeAsync
(List<Object> address, Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) Invokes the method returning aAsyncOperation
for the value.invokeFuture
(List<Object> address, Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) invokeSync
(List<Object> address, Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) Invokes the method, blocking until it returns on the remote end.void
setApplicationId
(ApplicationId applicationId) void
setRemoteInvokerRegistry
(RemoteInvokerRegistry remoteInvokerRegistry) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.getelements.elements.rt.remote.RoutingStrategy
invokeAsyncV
-
Constructor Details
-
DefaultRoutingStrategy
public DefaultRoutingStrategy()
-
-
Method Details
-
invokeFuture
public Future<Object> invokeFuture(List<Object> address, Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) Description copied from interface:RoutingStrategy
Invokes the method returning aFuture<Object>
with the result. Corresponds toRemoteInvoker.invokeFuture(Invocation, List, InvocationErrorConsumer)
.- Specified by:
invokeFuture
in interfaceRoutingStrategy
- Parameters:
address
- the addressinvocation
- theInvocation
asyncInvocationResultConsumerList
- the list ofConsumer<InvocationResult>
instancesasyncInvocationErrorConsumer
- theInvocationErrorConsumer
to receive the error of the invocation- Returns:
- the
Future<Object>
to handle the return value
-
invokeAsync
public AsyncOperation invokeAsync(List<Object> address, Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) Description copied from interface:RoutingStrategy
Invokes the method returning aAsyncOperation
for the value.- Specified by:
invokeAsync
in interfaceRoutingStrategy
- Parameters:
address
- the addressinvocation
- theInvocation
asyncInvocationResultConsumerList
- the list ofConsumer<InvocationResult>
instancesasyncInvocationErrorConsumer
- theInvocationErrorConsumer
to receive the error of the invocation- Returns:
- an instance of
AsyncOperation
-
invokeSync
public Object invokeSync(List<Object> address, Invocation invocation, List<Consumer<InvocationResult>> asyncInvocationResultConsumerList, InvocationErrorConsumer asyncInvocationErrorConsumer) throws Exception Description copied from interface:RoutingStrategy
Invokes the method, blocking until it returns on the remote end. Corresponds toRemoteInvoker.invokeFuture(Invocation, List, InvocationErrorConsumer)
.- Specified by:
invokeSync
in interfaceRoutingStrategy
- Parameters:
address
- the addressinvocation
- theInvocation
asyncInvocationResultConsumerList
- the list ofConsumer<InvocationResult>
instancesasyncInvocationErrorConsumer
- theInvocationErrorConsumer
to receive the error of the invocation- Returns:
- the return value of the remote invocation
- Throws:
Exception
-
getRemoteInvokerRegistry
-
setRemoteInvokerRegistry
-
getApplicationId
-
setApplicationId
-