Package akka.actor

Examples of akka.actor.Props


    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));
View Full Code Here


    // create the arraylist for holding the actors
    final List<ActorRef> routees = new ArrayList<ActorRef>(noOfInstances);
    for (int i = 0; i < noOfInstances; i++) {
      // initialize the actors and add to the arraylist
      routees.add(routeeProvider.context().actorOf(
          new Props(MsgEchoActor.class)));
    }
    // register the list
    routeeProvider.registerRoutees(routees);

    return new CustomRoute() {
View Full Code Here

   * @throws InterruptedException
   */
  public static void main(String[] args) throws InterruptedException {
    ActorSystem _system = ActorSystem.create("CustomRouteeRouterExample");
   
    ActorRef echoActor1 = _system.actorOf(new Props(MsgEchoActor.class));
    ActorRef echoActor2 = _system.actorOf(new Props(MsgEchoActor.class));
    ActorRef echoActor3 = _system.actorOf(new Props(MsgEchoActor.class));
   
    Iterable<ActorRef> routees = Arrays.asList(new ActorRef[] { echoActor1,
        echoActor2, echoActor3 });

    ActorRef randomRouter = _system.actorOf(new Props(MsgEchoActor.class)
        .withRouter(RandomRouter.create(routees)));

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

  /**
   * @param args
   */
  public static void main(String[] args) {
    ActorSystem system = ActorSystem.create("zeromqClientTest");
    system.actorOf(new Props(ClientActor.class)
        .withRouter(new RoundRobinRouter(3)), "client");
  }
View Full Code Here

  /**
   * @param args
   */
  public static void main(String[] args) {
    ActorSystem system = ActorSystem.create("zeromqServerTest");
    system.actorOf(new Props(ServerActor.class), "server");
  }
View Full Code Here

    int lowerBound = 2;
    int upperBound = 15;
    DefaultResizer resizer = new DefaultResizer(lowerBound, upperBound);

    ActorRef randomRouter = _system.actorOf(new Props(MsgEchoActor.class)
        .withRouter(new RandomRouter(resizer)));

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

    ActorRef actor1 = TypedActor.get(_system).getActorRefFor(calculator1);
    ActorRef actor2 = TypedActor.get(_system).getActorRefFor(calculator2);

    Iterable<ActorRef> routees = Arrays.asList(new ActorRef[] { actor1,
        actor2 });
    ActorRef router = _system.actorOf(new Props()
        .withRouter(BroadcastRouter.create(routees)));

    router.tell("Hello there");

    _system.shutdown();
View Full Code Here

  /**
   * @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);
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
View Full Code Here

    // 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);
View Full Code Here

TOP

Related Classes of akka.actor.Props

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.