@Override public void configure(@Nonnull final Env env, @Nonnull final Config conf, @Nonnull final Binder binder) { ActorSystem sys = ActorSystem.create(name, conf); env.serviceKey().generate(ActorSystem.class, name, syskey -> binder.bind(syskey).toInstance(sys)); }
clusterSystem = ActorSystem.create( clusterName, config );
/** * Inits the actor system. */ @PostConstruct public void initActorSystem() { LOG.info("Initializing Akka system..."); akka = ActorSystem.create(EPS, context.getConfig()); LOG.info("Initializing Akka EPS actor..."); opsActor = akka.actorOf(Props.create( new OperationsServerActor.ActorCreator(context)) .withDispatcher(CORE_DISPATCHER_NAME), EPS); LOG.info("Lookup platform protocols"); Set<String> platformProtocols = PlatformLookup.lookupPlatformProtocols( PlatformLookup.DEFAULT_PROTOCOL_LOOKUP_PACKAGE_NAME); LOG.info("Initializing Akka io router..."); ioRouter = akka.actorOf( new RoundRobinPool(context.getIoWorkerCount()) .withSupervisorStrategy(SupervisionStrategyFactory.createIoRouterStrategy(context)) .props(Props.create(new EncDecActor.ActorCreator(opsActor, context, platformProtocols)) .withDispatcher(IO_DISPATCHER_NAME)), IO_ROUTER_ACTOR_NAME); LOG.info("Initializing Akka event service listener..."); eventListener = new AkkaEventServiceListener(opsActor); context.getEventService().addListener(eventListener); clusterListener = new AkkaClusterServiceListener(opsActor); context.getClusterService().setListener(clusterListener); LOG.info("Initializing Akka system done"); }
/** * Create and get actor system. * * @return the actor system */ public static ActorSystem createAndGetActorSystem() { if (actorSystem == null || actorSystem.isTerminated()) { actorSystem = ActorSystem.create(PcConstants.ACTOR_SYSTEM, conf); } return actorSystem; }
public static void main(String[] args) throws Exception { ActorSystem _system = ActorSystem.create("FutureUsageExample"); ActorRef processOrder = _system.actorOf(new Props( ProcessOrderActor.class)); processOrder.tell(Integer.valueOf(456)); Thread.sleep(5000); _system.shutdown(); }
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(); }
/** * Create and get actor system. * * @return the actor system */ public static ActorSystem createAndGetActorSystem() { if (actorSystem == null || actorSystem.isTerminated()) { actorSystem = ActorSystem.create(PcConstants.ACTOR_SYSTEM, conf); } return actorSystem; }
/** * Creates an actor system with default configurations for Receiver actor. * * @return Actor System instance with default configurations */ private ActorSystem createDefaultActorSystem() { String defaultActorSystemName = "receiver-actor-system"; Config finalConfig = getOrCreateMandatoryProperties(configuration); return ActorSystem.create(defaultActorSystemName, finalConfig); }
public static void main(String[] args) { // note that client is not a compute node, role not defined ActorSystem system = ActorSystem.create("ClusterSystem", ConfigFactory.load("stats2")); system.actorOf(Props.create(StatsSampleClient.class, "/user/statsServiceProxy"), "client"); }
@Bean public ActorSystem actorSystem() { ActorSystem system = ActorSystem.create("akka-crimes-processing-system", akkaConfiguration()); springAkkaExtension.initialize(applicationContext); return system; }
public static void main(String[] args) { // note that client is not a compute node, role not defined ActorSystem system = ActorSystem.create("ClusterSystem", ConfigFactory.load("stats1")); system.actorOf(Props.create(StatsSampleClient.class, "/user/statsService"), "client"); } }
public static void main(String[] args) throws InterruptedException { System.out.println("Actor system create"); ActorSystem system = ActorSystem.create("system"); System.out.println("Actor system created"); ActorRef actor = system.actorOf(Props.create(SimpleActor.class)); System.out.println("Actor created"); actor.tell("Hello", ActorRef.noSender()); System.out.println("Wait 2 seconds"); TimeUnit.SECONDS.sleep(2); System.out.println("Shutting down"); system.shutdown(); }
public static void main(String[] args) { // Override the configuration of the port when specified as program argument final String port = args.length > 0 ? args[0] : "0"; final Config config = ConfigFactory.parseString( "akka.remote.netty.tcp.port=" + port + "\n" + "akka.remote.artery.canonical.port=" + port) .withFallback(ConfigFactory.parseString("akka.cluster.roles = [backend]")) .withFallback(ConfigFactory.load()); ActorSystem system = ActorSystem.create("ClusterSystem", config); system.actorOf(Props.create(TransformationBackend.class), "backend"); }
public static void main(String[] args) throws InterruptedException { ActorSystem system = ActorSystem.create("strategy", ConfigFactory.load("akka.config")); ActorRef routerTest = system.actorOf(Props.create(RouterTest.class), "RouterTest"); int i = 1; while(flag.get()){ routerTest.tell(TestActor.Msg.WORKING, ActorRef.noSender()); if(i % 10 == 0) routerTest.tell(TestActor.Msg.CLOSE, ActorRef.noSender()); Thread.sleep(500); i ++; } } }
public static void main(String[] args) { ActorSystem system = ActorSystem.create("Hello"); ActorRef a = system.actorOf(Props.create(HelloWorld.class), "helloWorld"); system.actorOf(Props.create(Terminator.class, a), "terminator"); }
public static void main(String[] args) { ActorSystem system = ActorSystem.create("system"); ActorRef actor = system.actorOf(Props.create(SimpleActor.class)); actor.tell("Hello", ActorRef.noSender()); system.shutdown(); }
public static void main(String[] args) { ActorSystem actorSystem = ActorSystem.create("TestSystem"); ActorRef ping = actorSystem.actorOf(Props.create(PingActor.class), "pingActor"); ping.tell("work", ActorRef.noSender()); ping.tell("reset", ActorRef.noSender()); }
@Override public void downloadAndIndex(final String path, final IndexWriter writer) { ActorSystem actorSystem = ActorSystem.create(); ActorRef master = actorSystem.actorOf(Props.create(SimpleActorMaster.class, new HtmlParserPageRetriever(path), writer)); master.tell(path, actorSystem.guardian()); actorSystem.awaitTermination(); }
@Override public void downloadAndIndex(String path, IndexWriter writer) { ActorSystem actorSystem = ActorSystem.create(); ActorRef master = actorSystem.actorOf(Props.create(ParallelMaster.class, new IndexerImpl(writer), new ChaosMonkeyPageRetriever(path))); master.tell(path, actorSystem.guardian()); actorSystem.awaitTermination(); }
@Override public void downloadAndIndex(final String path, final IndexWriter writer) { ActorSystem actorSystem = ActorSystem.create(); ActorRef master = actorSystem.actorOf(Props.create(ParallelMaster.class, new IndexerImpl(writer), new HtmlParserPageRetriever(path))); master.tell(path, actorSystem.guardian()); actorSystem.awaitTermination(); }