how to work with promise in play 2.0 framework

451 views Asked by At

i am working play 2.0 application with java.In that i am using promise for the Asynchronous sending of email.For that i followed http://www.playframework.org/documentation/2.0/JavaAsync

I tried like this:

Promise<Result> promiseOfInt = Akka.future(
        new Callable<Result>() {
        public Result call() {
        try {
        sendMail(form,to,sub,msg);
        } catch (MessagingException e) {
        e.printStackTrace();
        }
        return null; }  }  );

Then i got this error: [WARN] [09/07/2012 19:34:40.737] [New I/O worker #14] [Dispatchers] Dispatcher [akka.actor.promises-dispatcher] not configured, using default-dispatcher

I am new to the async programming in play.I am not getting how to handel the promise. Can any one help me.Kindly provide sample example. Thanks in Adv.

1

There are 1 answers

0
frankleonrose On

It's only a warning, but if it bugs you (like it did me) you'll need to add Akka configuration to your Play project.

See here Akka Configuration Docs for a sample of the file akka.conf. Put it in the /conf folder and add include "akka.conf" to application.conf

In order to configure the promises dispatcher, make sure yours includes:

akka { actor {
 ...
 promises-dispatcher = {
  throughput = 10 # For example
 }
 ...
}}

See other settings at Akka Dispatcher Docs