Class RemoteActorRef
java.lang.Object
com.scivicslab.pojoactor.core.distributed.RemoteActorRef
- All Implemented Interfaces:
CallableByActionName
Reference to an actor hosted on a remote node.
This class acts as a proxy for remote actor invocation. It implements
CallableByActionName and translates method calls into HTTP requests
to the remote node.
Usage Example
// Register remote node
system.registerRemoteNode("node1", "192.168.1.10", 8081);
// Get remote actor reference
RemoteActorRef remoteMath = system.getRemoteActor("node1", "math");
// Call remote actor (synchronous)
ActionResult result = remoteMath.callByActionName("add", "5,3");
System.out.println("Result: " + result.getResult());
Network Protocol
Sends HTTP POST request to:
POST http://node1:8081/actor/math/invoke
Content-Type: application/json
{
"actionName": "add",
"args": "5,3",
"messageId": "uuid-xxx"
}
- Since:
- 3.0.0, 3.0.0
- Author:
- devteam@scivics-lab.com
-
Constructor Summary
ConstructorsConstructorDescriptionRemoteActorRef(String actorName, NodeInfo nodeInfo) Constructs a new RemoteActorRef. -
Method Summary
Modifier and TypeMethodDescriptioncallByActionName(String actionName, String args) Invokes an action on the remote actor.Returns the name of the remote actor.Returns information about the node hosting this actor.toString()
-
Constructor Details
-
RemoteActorRef
Constructs a new RemoteActorRef.- Parameters:
actorName- the name of the remote actornodeInfo- information about the node hosting the actor
-
-
Method Details
-
callByActionName
Invokes an action on the remote actor.This method sends an HTTP POST request to the remote node and waits for the response synchronously.
- Specified by:
callByActionNamein interfaceCallableByActionName- Parameters:
actionName- the name of the action to invokeargs- the arguments for the action- Returns:
- the result of the action execution
-
getActorName
Returns the name of the remote actor.- Returns:
- the actor name
-
getNodeInfo
Returns information about the node hosting this actor.- Returns:
- the node information
-
toString
-