Package akka.actor

Examples of akka.actor.ActorRef


  public TestApp() {

    ActorSystem _system = ActorSystem.create("Extension-Test",
        ConfigFactory.load().getConfig("TestApp"));

    ActorRef ref = _system.actorOf(new Props(MyActor.class));
   
    ref.tell("msg");

    MySQLJDBCSettingsImpl mysqlSetting = MySQLJDBCSettings.SettingsProvider
        .get(_system);

    System.out.println(mysqlSetting.DB_NAME);
View Full Code Here


   */
  public static void main(String[] args) {
    ActorSystem _system = ActorSystem.create("callingThread-dispatcher",
        ConfigFactory.load().getConfig("MyDispatcherExample"));
   
    ActorRef actor = _system.actorOf(new Props(MsgEchoActor.class)
        .withDispatcher("CallingThreadDispatcher").withRouter(
            new RoundRobinRouter(2)));

    for (int i = 0; i < 5; i++) {
      actor.tell(i);
    }

    _system.shutdown();

  }
View Full Code Here

   */
  public static void main(String[] args) {
    ActorSystem _system = ActorSystem.create("default-dispatcher",
        ConfigFactory.load().getConfig("MyDispatcherExample"));
   
    ActorRef actor = _system.actorOf(new Props(MsgEchoActor.class)
        .withDispatcher("defaultDispatcher1").withRouter(
            new RoundRobinRouter(5)));

    for (int i = 0; i < 25; i++) {
      actor.tell(i);
    }

    _system.shutdown();

  }
View Full Code Here

   */
  public static void main(String[] args) {
    ActorSystem _system = ActorSystem.create("pinned-dispatcher",
        ConfigFactory.load().getConfig("MyDispatcherExample"));
   
    ActorRef actor = _system.actorOf(new Props(MsgEchoActor.class)
        .withDispatcher("pinnedDispatcher").withRouter(
            new RoundRobinRouter(5)));

    for (int i = 0; i < 25; i++) {
      actor.tell(i);
    }

    _system.shutdown();

  }
View Full Code Here

   */
  public static void main(String[] args) {
    ActorSystem _system = ActorSystem.create("balancing-dispatcher",
        ConfigFactory.load().getConfig("MyDispatcherExample"));
   
    ActorRef actor = _system.actorOf(new Props(MsgEchoActor.class)
        .withDispatcher("balancingDispatcher1").withRouter(
            new RoundRobinRouter(5)));

    for (int i = 0; i < 25; i++) {
      actor.tell(i);
    }

    _system.shutdown();

  }
View Full Code Here

public class Example1 {
  public static void main(String[] args) {
    ActorSystem _system = ActorSystem.create("default-dispatcher",
        ConfigFactory.load().getConfig("MyDispatcherExample"));
   
    ActorRef actor = _system.actorOf(new Props(MsgEchoActor.class)
        .withDispatcher("defaultDispatcher").withRouter(
            new RoundRobinRouter(5)));

    for (int i = 0; i < 25; i++) {
      actor.tell(i);
    }

    _system.shutdown();
  }
View Full Code Here

   */
  public static void main(String[] args) {
    ActorSystem _system = ActorSystem.create("balancing-dispatcher",
        ConfigFactory.load().getConfig("MyDispatcherExample"));
   
    ActorRef actor = _system.actorOf(new Props(MsgEchoActor.class)
        .withDispatcher("balancingDispatcher").withRouter(
            new RoundRobinRouter(5)));

    for (int i = 0; i < 25; i++) {
      actor.tell(i);
    }

    _system.shutdown();

  }
View Full Code Here

   * @throws InterruptedException
   */
  public static void main(String[] args) throws InterruptedException {
    ActorSystem _system = ActorSystem.create("RandomRouterExample",
        ConfigFactory.load().getConfig("MyRouterExample"));
    ActorRef randomRouter = _system.actorOf(
        new Props(MsgEchoActor.class).withRouter(new FromConfig()),
        "myRandomRouterActor");

    for (int i = 1; i <= 10; i++) {
      // sends randomly to actors
      randomRouter.tell(i);
    }
    _system.shutdown();
  }
View Full Code Here

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

    Integer originalValue = Integer.valueOf(0);

    ActorRef supervisor = system.actorOf(new Props(SupervisorActor.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

  }

  @Test
  public void stopTest() throws Exception {

    ActorRef workerActor1 = supervisor.underlyingActor().workerActor1;
    ActorRef workerActor2 = supervisor.underlyingActor().workerActor2;

    TestProbe probe1 = new TestProbe(_system);
    TestProbe probe2 = new TestProbe(_system);
    probe1.watch(workerActor1);
    probe2.watch(workerActor2);
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.