Package akka.actor

Examples of akka.actor.ActorSystem


  @Test
  public void systemActorOf() {
    //#system-actorOf
    // ActorSystem is a heavy object: create only one per application
    final ActorSystem system = ActorSystem.create("MySystem");
    final ActorRef myActor = system.actorOf(Props.create(MyUntypedActor.class),
      "myactor");
    //#system-actorOf
    try {
      new JavaTestKit(system) {
        {
View Full Code Here


  public static class Connection {
  }

  @Test
  public void demonstrateHowToCreateAndUseAnAkkaExtensionInJava() {
    final ActorSystem system = null;
    try {
      //#extension-usage
      // typically you would use static import of the Settings.SettingsProvider field
      String dbUri = Settings.SettingsProvider.get(system).DB_URI;
      //#extension-usage
View Full Code Here

        ConfigFactory.load(("calculator")));
    System.out.println("Started CalculatorWorkerSystem");
  }

  public static void startRemoteCreationSystem() {
    final ActorSystem system = ActorSystem.create("CreationSystem",
        ConfigFactory.load("remotecreation"));
    final ActorRef actor = system.actorOf(Props.create(CreationActor.class),
        "creationActor");

    System.out.println("Started CreationSystem");
    final Random r = new Random();
    system.scheduler().schedule(Duration.create(1, SECONDS),
        Duration.create(1, SECONDS), new Runnable() {
          @Override
          public void run() {
            if (r.nextInt(100) % 2 == 0) {
              actor.tell(new Op.Multiply(r.nextInt(100), r.nextInt(100)), null);
            } else {
              actor.tell(new Op.Divide(r.nextInt(10000), r.nextInt(99) + 1),
                  null);
            }
          }
        }, system.dispatcher());
  }
View Full Code Here

    if (args.length == 0 || args[0].equals("Lookup"))
      startRemoteLookupSystem();
  }

  public static void startRemoteCalculatorSystem() {
    final ActorSystem system = ActorSystem.create("CalculatorSystem",
        ConfigFactory.load(("calculator")));
    system.actorOf(Props.create(CalculatorActor.class), "calculator");
    System.out.println("Started CalculatorSystem");
  }
View Full Code Here

    System.out.println("Started CalculatorSystem");
  }

  public static void startRemoteLookupSystem() {

    final ActorSystem system = ActorSystem.create("LookupSystem",
        ConfigFactory.load("remotelookup"));
    final String path = "akka.tcp://CalculatorSystem@127.0.0.1:2552/user/calculator";
    final ActorRef actor = system.actorOf(
        Props.create(LookupActor.class, path), "lookupActor");

    System.out.println("Started LookupSystem");
    final Random r = new Random();
    system.scheduler().schedule(Duration.create(1, SECONDS),
        Duration.create(1, SECONDS), new Runnable() {
          @Override
          public void run() {
            if (r.nextInt(100) % 2 == 0) {
              actor.tell(new Op.Add(r.nextInt(100), r.nextInt(100)), null);
            } else {
              actor.tell(new Op.Subtract(r.nextInt(100), r.nextInt(100)), null);
            }

          }
        }, system.dispatcher());

  }
View Full Code Here

    final Config config = ConfigFactory.parseString(
        "akka.cluster.roles = [frontend]").withFallback(
        ConfigFactory.load("factorial"));

    final ActorSystem system = ActorSystem.create("ClusterSystem", config);
    system.log().info(
        "Factorials will start when 2 backend members in the cluster.");
    //#registerOnUp
    Cluster.get(system).registerOnMemberUp(new Runnable() {
      @Override
      public void run() {
        system.actorOf(Props.create(FactorialFrontend.class, upToN, true),
            "factorialFrontend");
      }
    });
    //#registerOnUp
  }
View Full Code Here

    final String port = args.length > 0 ? args[0] : "0";
    final Config config = ConfigFactory.parseString("akka.remote.netty.tcp.port=" + port).
      withFallback(ConfigFactory.parseString("akka.cluster.roles = [backend]")).
      withFallback(ConfigFactory.load("factorial"));

    ActorSystem system = ActorSystem.create("ClusterSystem", config);

    system.actorOf(Props.create(FactorialBackend.class), "factorialBackend");

    system.actorOf(Props.create(MetricsListener.class), "metricsListener");

  }
View Full Code Here

    // put the result in between the overrides
    // (system props) and defaults again
    Config complete =
      ConfigFactory.load(combined);
    // create ActorSystem
    ActorSystem system =
      ActorSystem.create("myname", complete);
    //#java-custom-config
    return system;
  }
View Full Code Here

public class CamelExtensionTest {
  @Test
  public void getCamelExtension() {
    //#CamelExtension
    ActorSystem system = ActorSystem.create("some-system");
    Camel camel = CamelExtension.get(system);
    CamelContext camelContext = camel.context();
    ProducerTemplate producerTemplate = camel.template();
    //#CamelExtension
    JavaTestKit.shutdownActorSystem(system);
View Full Code Here

    //#CamelExtension
    JavaTestKit.shutdownActorSystem(system);
  }
  public void addActiveMQComponent() {
    //#CamelExtensionAddComponent
    ActorSystem system = ActorSystem.create("some-system");
    Camel camel = CamelExtension.get(system);
    CamelContext camelContext = camel.context();
    // camelContext.addComponent("activemq", ActiveMQComponent.activeMQComponent(
    //   "vm://localhost?broker.persistent=false"));
    //#CamelExtensionAddComponent
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.