Package akka.actor

Examples of akka.actor.ActorSystem


  /**
   * @param args
   */
  public static void main(String[] args) {
    ActorSystem _system = ActorSystem.create("CustomRouterExample");
    ActorRef burstyMessageRouter = _system.actorOf(new Props(
        MsgEchoActor.class).withRouter(new BurstyMessageRouter(5,2)));

    for (int i = 1; i <= 13; i++) {
      //sends series of messages in a round robin way to all the actors
      burstyMessageRouter.tell(i);
    }
    _system.shutdown();

  }
View Full Code Here


  /**
   * @param args
   */
  public static void main(String[] args) {
    ActorSystem _system = ActorSystem.create("SmallestMailBoxRouterExample");
    ActorRef smallestMailBoxRouter = _system.actorOf(new Props(MsgEchoActor.class)
        .withRouter(new SmallestMailboxRouter(5)),"mySmallestMailBoxRouterActor");

    for (int i = 1; i <= 10; i++) {
      //works like roundrobin but tries to rebalance the load based on
      //size of actor's mailbox
      smallestMailBoxRouter.tell(i);
    }
    _system.shutdown();

  }
View Full Code Here

   * @param args
   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    // TODO Auto-generated method stub
    ActorSystem system = ActorSystem.create("DurableMailBox", ConfigFactory
        .load().getConfig("myapp1"));

    ActorRef actor = system
        .actorOf(new Props(DurableMailBox.class)
            .withDispatcher("my-dispatcher"), "serverActor");

    actor.tell("Hello");

    Thread.sleep(500);

    system.shutdown();

  }
View Full Code Here

  /**
   * @param args
   */
  public static void main(String[] args) {
    ActorSystem system = ActorSystem.create("zeromqTest");
    system.actorOf(new Props(WorkerTaskA.class), "workerA");
    system.actorOf(new Props(WorkerTaskB.class), "workerB");
    system.actorOf(new Props(RouterActor.class), "router");
  }
View Full Code Here

  /**
   * @param args
   */
  public static void main(String[] args) {
    ActorSystem _system = ActorSystem.create("BroadcastRouterExample");
    ActorRef broadcastRouter = _system.actorOf(new Props(MsgEchoActor.class)
        .withRouter(new BroadcastRouter(5)),"myBroadcastRouterActor");

    for (int i = 1; i <= 2; i++) {
      //same message goes to all the actors
      broadcastRouter.tell(i);
    }
    _system.shutdown();

  }
View Full Code Here

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

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

  /**
   * @param args
   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    ActorSystem _system = ActorSystem
        .create("ScatterGatherFirstCompletedRouterExample");
    ActorRef scatterGatherFirstCompletedRouter = _system.actorOf(new Props(
        RandomTimeActor.class)
        .withRouter(new ScatterGatherFirstCompletedRouter(5, Duration
            .create(2, "seconds"))),
        "myScatterGatherFirstCompletedRouterActor");

    Timeout timeout = new Timeout(Duration.create(10, "seconds"));
    Future<Object> futureResult = akka.pattern.Patterns.ask(
        scatterGatherFirstCompletedRouter, "message", timeout);
    String result = (String) Await.result(futureResult, timeout.duration());
    System.out.println(result);

    _system.shutdown();

  }
View Full Code Here

  /**
   * @param args
   */
  public static void main(String[] args) {
    ActorSystem system = ActorSystem.create("zeromqTest");
    system.actorOf(new Props(PushActor.class), "push");
    system.actorOf(new Props(PullActor1.class), "pull1");
    system.actorOf(new Props(PullActor2.class), "pull2");
  }
View Full Code Here

  /**
   * @param args
   * @throws InterruptedException
   */
  public static void main(String[] args) throws InterruptedException {
    ActorSystem _system = ActorSystem.create("RoundRobinRouterExample");
    ActorRef roundRobinRouter = _system.actorOf(new Props(
        MsgEchoActor.class).withRouter(new RoundRobinRouter(5)),"myRoundRobinRouterActor");

    for (int i = 1; i <= 10; i++) {
      //sends messages in a round robin way to all the actors
      roundRobinRouter.tell(i);
      if (i == 5) {
        TimeUnit.MILLISECONDS.sleep(100);
        System.out.println("\n");
      }
    }
    _system.shutdown();
  }
View Full Code Here

  /**
   * @param args
   */
  public static void main(String[] args) {
    ActorSystem system = ActorSystem.create("zeromqTest");
    system.actorOf(new Props(WorkerTaskA.class), "workerA");
    system.actorOf(new Props(WorkerTaskB.class), "workerB");
    system.actorOf(new Props(PublisherActor.class), "publisher");
  }
View Full Code Here

TOP

Related Classes of akka.actor.ActorSystem

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.