How to use MongoDB Async Java Driver in Play Framework 2.x action?

73 views
Skip to first unread message

Saeed Zarinfam

unread,
Aug 2, 2015, 2:12:05 AM8/2/15
to play-framework

I want to use MongoDB Async Java Driver in a Play Framework 2 project, MongoDB Async Java Driver return SingleResponseCallback. I do not know how to handle this kind of result in Play controllers.

For example how to return count from the following code in a Play controller:

collection.count(
 new SingleResultCallback<Long>() {
  @Override
  public void onResult(final Long count, final Throwable t) {
      System.out.println(count);
  }
});

How can i get result from SingleResultCallback and then convert it to Promise? is it good way? What is the best practice in this situations?


Reply all
Reply to author
Forward
0 new messages