Package akka.actor

Examples of akka.actor.ActorRef


    LoggingAdapter log = Logging.getLogger(system, system);

    Integer originalValue = Integer.valueOf(0);

    ActorRef supervisor = system.actorOf(new Props(SupervisorActor2.class),
        "supervisor");

    log.info("Sending value 8, no exceptions should be thrown! ");
    supervisor.tell(Integer.valueOf(8));

    Integer result = (Integer) Await.result(
        Patterns.ask(supervisor, new Result(), 5000),
        Duration.create(5000, TimeUnit.MILLISECONDS));

    log.info("Value Received-> {}", result);
    assert result.equals(Integer.valueOf(8));

    log.info("Sending value -8, ArithmeticException should be thrown! Our Supervisor strategy says resume !");
    supervisor.tell(Integer.valueOf(-8));

    result = (Integer) Await.result(
        Patterns.ask(supervisor, new Result(), 5000),
        Duration.create(5000, TimeUnit.MILLISECONDS));

    log.info("Value Received-> {}", result);
    assert result.equals(Integer.valueOf(8));

    log.info("Sending value null, NullPointerException should be thrown! Our Supervisor strategy says restart !");
    supervisor.tell(null);

    result = (Integer) Await.result(
        Patterns.ask(supervisor, new Result(), 5000),
        Duration.create(5000, TimeUnit.MILLISECONDS));

    log.info("Value Received-> {}", result);
    assert originalValue.equals(result);

    log.info("Sending value \"String\", IllegalArgumentException should be thrown! Our Supervisor strategy says Stop !");

    supervisor.tell(String.valueOf("Do Something"));

    log.info("Worker Actor shutdown !");
    system.shutdown();

  }
View Full Code Here


    // load the configuration
    system = ActorSystem.create("ServerSys", ConfigFactory.load()
        .getConfig("ServerSys"));
    log = Logging.getLogger(system, this);
    // create the actor
    @SuppressWarnings("unused")
    ActorRef actor = system.actorOf(new Props(ServerActor.class),
        "serverActor");
  }
View Full Code Here

   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    ActorSystem system = ActorSystem.create("faultTolerance");

    ActorRef supervisor = system.actorOf(new Props(SupervisorActor.class),
        "supervisor");

    supervisor.tell(Integer.valueOf(10));
    supervisor.tell("10");

    Thread.sleep(5000);

    supervisor.tell(Integer.valueOf(10));

    system.shutdown();
  }
View Full Code Here

public class TestActorSystem {

  public static void main(String[] args) throws Exception {
    ActorSystem _system = ActorSystem.create("FutureUsageExample");
    ActorRef processOrder = _system.actorOf(new Props(
        ProcessOrderActor.class));
    processOrder.tell(Integer.valueOf(456));

    Thread.sleep(5000);

    _system.shutdown();
  }
View Full Code Here

    final String fileName = "Othello.txt";

    ActorSystem system = ActorSystem.create("ClientApplication",
        ConfigFactory.load().getConfig("WCMapReduceClientApp"));

    final ActorRef fileReadActor = system.actorOf(new Props(
        FileReadActor.class));

    final ActorRef remoteActor = system
        .actorFor("akka://WCMapReduceApp@127.0.0.1:2552/user/WCMapReduceActor");

    @SuppressWarnings("serial")
    ActorRef actor = system.actorOf(new Props(new UntypedActorFactory() {
      public UntypedActor create() {
        return new ClientActor(remoteActor);
      }
    }));
View Full Code Here

    final int no_of_workers = 10;

    system = ActorSystem.create("LoadGeneratorApp");

    final ActorRef appManager = system.actorOf(
        new Props(new UntypedActorFactory() {
          public UntypedActor create() {
            return new JobControllerActor(no_of_msgs);
          }
        }), "jobController");
View Full Code Here

public class MyActorSystem {

  public static void main(String[] args) throws Exception {

    ActorSystem _system = ActorSystem.create("BecomeUnbecome");
    ActorRef pingPongActor = _system
        .actorOf(new Props(PingPongActor.class));

    pingPongActor.tell(PingPongActor.PING, pingPongActor);

    Thread.sleep(2000);

    _system.shutdown();
View Full Code Here

    counterResult = calculator.incrementAndReturn();
    System.out.println("Result is " + counterResult.get());

    // Get access to the ActorRef
    ActorRef calActor = TypedActor.get(_system).getActorRefFor(calculator);
    // call actor with a message
    calActor.tell("Hi there");
   
    _system.shutdown();

  }
View Full Code Here

  }

  @Test
  public void stopTest() throws Exception {

    ActorRef workerActor = supervisor.underlyingActor().childActor;
    TestProbe probe = new TestProbe(_system);
    probe.watch(workerActor);

    supervisor.tell(Long.parseLong("10"));
View Full Code Here

*/
public class LocalNodeApplication {
  public static void main(String[] args) throws Exception {
    ActorSystem _system = ActorSystem.create("LocalNodeApp",ConfigFactory
        .load().getConfig("LocalSys"));
    ActorRef localActor = _system.actorOf(new Props(LocalActor.class));
    localActor.tell("Hello");

    Thread.sleep(5000);
    _system.shutdown();
  }
View Full Code Here

TOP

Related Classes of akka.actor.ActorRef

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.