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.

Implements CallableByActionName and translates method calls into messages delivered via the configured TransportLayer.

Usage Example (HTTP transport)


 RemoteActorRef remoteMath = new RemoteActorRef("math", nodeInfo);
 ActionResult result = remoteMath.callByActionName("add", "5,3");
 

Usage Example (Kafka transport)


 KafkaTransport transport = new KafkaTransport(myNode, "kafka-broker:9092");
 RemoteActorRef remoteMath = new RemoteActorRef("math", nodeInfo, transport);
 ActionResult result = remoteMath.callByActionName("add", "5,3");
 
Since:
3.0.0
  • Constructor Details

    • RemoteActorRef

      public RemoteActorRef(String actorName, NodeInfo nodeInfo)
      Constructs a RemoteActorRef using the default HTTP transport.
      Parameters:
      actorName - the name of the remote actor
      nodeInfo - information about the node hosting the actor
    • RemoteActorRef

      public RemoteActorRef(String actorName, NodeInfo nodeInfo, TransportLayer transport)
      Constructs a RemoteActorRef with an explicit transport layer.
      Parameters:
      actorName - the name of the remote actor
      nodeInfo - information about the node hosting the actor
      transport - the transport to use for message delivery
  • Method Details

    • callByActionName

      public ActionResult callByActionName(String actionName, String args)
      Invokes an action on the remote actor and waits for the result.
      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()
    • getNodeInfo

      public NodeInfo getNodeInfo()
    • getTransport

      public TransportLayer getTransport()
    • toString

      public String toString()
      Overrides:
      toString in class Object