Package akka.actor

Examples of akka.actor.ActorSystem


   */
  public static void main(String[] args) {

    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);
      }
    }));

    fileReadActor.tell(fileName,actor);

    remoteActor.tell("DISPLAY_LIST");

    system.shutdown();

  }
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

import com.typesafe.config.ConfigFactory;

public class CalculatorActorSytem {

  public static void main(String[] args) throws Exception {
    ActorSystem _system = ActorSystem.create("TypedActorsExample",
        ConfigFactory.load().getConfig("TypedActorExample"));

    Timeout timeout = new Timeout(Duration.parse("5 seconds"));

    CalculatorInt calculator = TypedActor.get(_system).typedActorOf(
        new TypedProps<Calculator>(CalculatorInt.class,
            Calculator.class).withDispatcher("defaultDispatcher"));

    // calling a fire and forget method
    calculator.incrementCount();

    // Invoke the method and wait for result
    Future<Integer> future = calculator.add(Integer.valueOf(14),
        Integer.valueOf(6));
    Integer result = Await.result(future, timeout.duration());

    System.out.println("Result is " + result);

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

    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

* Hello world!
*
*/
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

public class TestApp {

  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);
    System.out.println(mysqlSetting.DB_URL);

    _system.shutdown();
  }
View Full Code Here

public class Example {
  /**
   * @param args
   */
  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

  /**
   * @param args
   */
  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

  /**
   * @param args
   */
  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 class Example2 {
  /**
   * @param args
   */
  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

* Hello world!
*
*/
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

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.