Class RemoteActorRef

java.lang.Object
com.scivicslab.pojoactor.core.distributed.RemoteActorRef
All Implemented Interfaces:
CallableByActionName

public class RemoteActorRef extends Object implements 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 Details

    • RemoteActorRef

      public RemoteActorRef(String actorName, NodeInfo nodeInfo)
      Constructs a new RemoteActorRef.
      Parameters:
      actorName - the name of the remote actor
      nodeInfo - information about the node hosting the actor
  • Method Details

    • callByActionName

      public ActionResult callByActionName(String actionName, String args)
      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:
      callByActionName in interface CallableByActionName
      Parameters:
      actionName - the name of the action to invoke
      args - the arguments for the action
      Returns:
      the result of the action execution
    • getActorName

      public String getActorName()
      Returns the name of the remote actor.
      Returns:
      the actor name
    • getNodeInfo

      public NodeInfo getNodeInfo()
      Returns information about the node hosting this actor.
      Returns:
      the node information
    • toString

      public String toString()
      Overrides:
      toString in class Object