ActorRef myActor = Akka.system().actorOf(new Props(MyGeneratorMaster.class));
ActorRef child = this.getContext().actorOf(new Props(MyGeneratorChildWorker.class));
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(); }
final ActorSystem actorSystem = ActorSystem.create("ServerEvents"); final ActorRef actor = actorSystem.actorOf(new Props(SeverEventHandler.class)); actorSystem.eventStream().subscribe(actor,ServerMessage.class); actorSystem.eventStream().publish(new ServerMessage()); <<== add this
public class MyParent extends UntypedActor { final Props workerProps; public MyParent() { workerProps = new Props(...); } public MyParent(Props p) { workerProps = p; } ... getContext().actorOf(workerProps, "worker"); }
if (masterInventory[iterator] instanceof Collectible) { itemToReturn = new Collectible((Collectible) masterInventory[iterator]); } if (masterInventory[iterator] instanceof Props) { itemToReturn = new Props((Props) masterInventory[iterator]); }
ActorRef myActor = system.actorOf(new Props(new UntypedActorFactory() { public UntypedActor create() { return new MyActor("..."); } }), "myactor");
private ActorRef tts(final Configuration configuration) { final String classpath = configuration.getString("[@class]"); final Props props = new Props(new UntypedActorFactory() { private static final long serialVersionUID = 1L; @Override public Actor create() throws Exception { return (UntypedActor) Class.forName(classpath).getConstructor(Configuration.class).newInstance(configuration); } }); return system.actorOf(props); }
private ActorRef session(final Configuration configuration) { final Props props = new Props(new UntypedActorFactory() { private static final long serialVersionUID = 1L; @Override public Actor create() throws Exception { return new EmailService(configuration); } }); return system.actorOf(props); }
private ActorRef observer() { final Props props = new Props(new UntypedActorFactory() { private static final long serialVersionUID = 1L; @Override public UntypedActor create() throws Exception { return new EmailSessionObserver(); } }); return system.actorOf(props); }
private ActorRef cache(final String path, final String uri) { final Props props = new Props(new UntypedActorFactory() { private static final long serialVersionUID = 1L; @Override public Actor create() throws Exception { return new DiskCacheFactory(configuration).getDiskCache(path, uri); } }); return system.actorOf(props); }
private ActorRef observer() { final Props props = new Props(new UntypedActorFactory() { private static final long serialVersionUID = 1L; @Override public UntypedActor create() throws Exception { return new SmsSessionObserver(); } }); return system.actorOf(props); }
@Override public ActorRef getUSSDDataRecorder() { return system.actorOf(new Props(this.ussdDataRecorderFactory)); }
public static void main(String[] args) { ActorSystem system = ActorSystem.create("BettingProcessorActorSystem", ConfigFactory.load()); ActorRef bettingProcessor = system.actorOf(new Props(BettingProcessor.class), "bettingProcessor"); } }
public static void main(String[] args) { ActorSystem system = ActorSystem.create("BettingServiceActorSystem", ConfigFactory.load()); system.actorOf(new Props(BettingService.class), "bettingService"); } }
private ActorRef gateway() { final Props props = new Props(new UntypedActorFactory() { private static final long serialVersionUID = 1L; @Override public UntypedActor create() throws Exception { final String classpath = configuration.getString("mgcp-server[@class]"); return (UntypedActor) new ObjectFactory(loader).getObjectInstance(classpath); } }); return getContext().actorOf(props); }
private ActorRef httpAsycClientHelper(){ final Props props = new Props(new UntypedActorFactory() { private static final long serialVersionUID = 1L; @Override public UntypedActor create() throws Exception { return new HttpAsycClientHelper(); } }); return getContext().actorOf(props); }
protected ActorRef createMediaGroup(final Object message) { final Props props = new Props(new UntypedActorFactory() { protected static final long serialVersionUID = 1L; @Override public UntypedActor create() throws Exception { return new MgcpMediaGroup(localMediaGateway, localMediaSession, localConfernceEndpoint); } }); return getContext().actorOf(props); }
private ActorRef getConnection(final Object message) { final CreateConnection request = (CreateConnection) message; final MediaSession session = request.session(); final ActorRef gateway = self(); final Props props = new Props(new UntypedActorFactory() { private static final long serialVersionUID = 1L; @Override public UntypedActor create() throws Exception { return new Connection(gateway, session, agent, timeout); } }); return getContext().actorOf(props); }