Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- */
- package com.akkasample;
- import com.akkasample.actor.MessageActor;
- import com.akkasample.bean.Greeting;
- import akka.actor.ActorRef;
- import akka.actor.ActorSelection;
- import akka.actor.ActorSystem;
- import akka.actor.Props;
- /**
- * @author Rakesh
- *
- */
- public class AkkaSampleMain {
- /**
- * @param args
- * @throws Exception
- */
- public static void main(String[] args){
- // Create Actor System
- ActorSystem system = ActorSystem.create("SampleActorSystem");
- //Create Actor in the system
- ActorRef ref = system.actorOf(Props.create(MessageActor.class),"MessageActor");
- // Pass message to Actor
- ref.tell(new Greeting("Hello Akka!!! "),ActorRef.noSender());
- //Get Actor reference using the actor path in the system
- ActorSelection existingActor = system.actorSelection("/user/MessageActor");
- existingActor.tell(new Greeting("Message to existing actor"), ActorRef.noSender());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement