Is it a fire and forget action? Is the Actor a "singleton" or a per request
actor?
Here is code for a fire and forget singleton:
At the top of your controller add:
private static final ActorRef myActor =
Akka.system().actorOf(Props.create(MyActorClass.class), "MyActorName");
Then where your comment is do:
myActor.tell("Some Message or Some Class", ActorRef.noSender());
If you are trying to do something else, a per request actor or you need a
reply, answer with what you need.
Chanan
On Thursday, April 30, 2015 at 3:38:26 AM UTC-4, Nweike Onwuyali wrote:
>
> I am using Play Controller action to make a REST call. But on success of
> that call, i want to Trigger a service implemented as a Akka Actor.
>
> Below is my code for making the REST call with a controller action. I need
> help how to insert the code to trigger the service on the Akka Actor
> <xmp>
>
> public static Promise<Result> create() throws Exception{
>
> Promise<Result> resultPromise=null;
> try {
> User user = getRegisteredUser();
> DataRequestObject dataRequestObject= new DataRequestObject(new
> HashMap(), RequestMethod.POST,getClientIpAddr());
> Promise<WSResponse> responsePromise =
> user.save(UserStep.REGISTRATION,
> DataRepositoryStrategy.CLOUDANT,WS.client(),dataRequestObject);
> resultPromise = responsePromise.map(
> new Function<WSResponse, Result>() {
> @Override
> public Result apply(WSResponse response) throws Exception
> {
> ResponseObject responseObject =
> DBECodesFactory.getResponseObject(response.asJson(), new String[]{"email",
> user.name.username});
> if (responseObject.isSuccess()) {
> // Trigger Akka Actor Service
> return ok(views.html.postreg.render());
> } else {
> flash("error", responseObject.getFailureReason());
> return redirect(routes.Users.register());//
> ok(views.html.register.render());
>
> }
> }
> });
>
> }catch (Exception d){
> Logger.getLogger("NEW REGISTRATION").log(Level.SEVERE, d.toString(),
> d);
> d.printStackTrace();
> throw new Exception(d);
> }
> return resultPromise;
>
>
>
> }
>
> </xmp>
>
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.