Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. /**
  2. *
  3. */
  4. package com.akkasample;
  5.  
  6. import com.akkasample.actor.MessageActor;
  7. import com.akkasample.bean.Greeting;
  8.  
  9. import akka.actor.ActorRef;
  10. import akka.actor.ActorSelection;
  11. import akka.actor.ActorSystem;
  12. import akka.actor.Props;
  13.  
  14. /**
  15. * @author Rakesh
  16. *
  17. */
  18. public class AkkaSampleMain {
  19.  
  20. /**
  21. * @param args
  22. * @throws Exception
  23. */
  24. public static void main(String[] args){
  25.  
  26. // Create Actor System
  27. ActorSystem system = ActorSystem.create("SampleActorSystem");
  28. //Create Actor in the system
  29. ActorRef ref = system.actorOf(Props.create(MessageActor.class),"MessageActor");
  30. // Pass message to Actor
  31. ref.tell(new Greeting("Hello Akka!!! "),ActorRef.noSender());
  32.  
  33. //Get Actor reference using the actor path in the system
  34. ActorSelection existingActor = system.actorSelection("/user/MessageActor");
  35. existingActor.tell(new Greeting("Message to existing actor"), ActorRef.noSender());
  36.  
  37.  
  38. }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement