在playframework2.0中使用akka promise/future的例外情况
我使用PlayFramework2.0作为一个简单的应用程序,该应用程序从MySQL数据库返回json字符串形式的员工列表。我的控制器如下在playframework2.0中使用akka promise/future的例外情况,akka,playframework-2.0,Akka,Playframework 2.0,我使用PlayFramework2.0作为一个简单的应用程序,该应用程序从MySQL数据库返回json字符串形式的员工列表。我的控制器如下 public class Application extends Controller { public static Result getEmployees() { Logger.info("enter getting employee information"); Promise <List<Employe
public class Application extends Controller {
public static Result getEmployees() {
Logger.info("enter getting employee information");
Promise <List<Employee>> employeeList = Akka.future(new Callable<List<Employee>>(){
public List<Employee> call() {
return Employee.getAll();
}
});
return async(
employeeList.map(
new Function<List<Employee>,Result>() {
@Override
public Result apply(List<Employee> employeeList)
{
// TODO Auto-generated method stub
try {
if (employeeList!=null) {
return ok(Json.toJson(employeeList));
} else {
return ok("");
}
} catch (Exception e) {
return ok("");
}
}
}
)
);
}
}
我得到以下错误
[error] play - Waiting for a promise, but got an error: null
java.lang.RuntimeException: null
我的Akka特定配置是
play {
akka {
event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
loglevel = WARNING
actor {
deployment {
/actions {
router = round-robin
nr-of-instances = 100
}
/promises {
router = round-robin
nr-of-instances = 100
}
}
retrieveBodyParserTimeout = 4 second
actions-dispatcher = {
fork-join-executor {
parallelism-factor = 1
parallelism-max = 100
}
}
promises-dispatcher = {
fork-join-executor {
parallelism-factor = 1
parallelism-max = 100
}
}
websockets-dispatcher = {
fork-join-executor {
parallelism-factor = 1
parallelism-max = 100
}
}
default-dispatcher = {
fork-join-executor {
parallelism-factor = 1
parallelism-max = 100
}
}
}
}
}
[error] play - Waiting for a promise, but got an error: null
java.lang.RuntimeException: null
play {
akka {
event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
loglevel = WARNING
actor {
deployment {
/actions {
router = round-robin
nr-of-instances = 100
}
/promises {
router = round-robin
nr-of-instances = 100
}
}
retrieveBodyParserTimeout = 4 second
actions-dispatcher = {
fork-join-executor {
parallelism-factor = 1
parallelism-max = 100
}
}
promises-dispatcher = {
fork-join-executor {
parallelism-factor = 1
parallelism-max = 100
}
}
websockets-dispatcher = {
fork-join-executor {
parallelism-factor = 1
parallelism-max = 100
}
}
default-dispatcher = {
fork-join-executor {
parallelism-factor = 1
parallelism-max = 100
}
}
}
}
}