Playframework – Plays 2 views of views WebService call without using AsyncResult

Play 2 allows you to execute async webservice calls through AsyncResult without blocking the thread:

public static Result feedTitle( String feedUrl) {
return async(
WS.url(feedUrl).get().map(
new Function() {
public Result apply(WS.Response response) {
return ok("Feed title:" + response.asJson().findPath("title"));
}
}
)
);
}

This only applies if you are performing simple operations, such as passing the result of a WS call directly to the user. However, if you have to perform other operations on the result ,What should I do?

Look at the documentation, it looks like you can do this:

Promise promise = WS.url("http://some. website.com").get();
Response response = promise.get(); // I've got the result, but I've also blocked

This is obviously not ideal Is there a way to make asynchronous calls while allowing Play to pass execution to other threads?

Take a look at https://github.com/jroper/play-promise-presentation. This is for How do I design a system that may have multiple promise calls, etc., and manipulate various promise responses to the content required for more complex responses, etc., I really know.

The most The good part is-this example does not feel too verbose. It is very well read and very simple to understand.

Play 2 allows you to perform async webservice calls via AsyncResult, It does not block the thread:

public static Result feedTitle(String feedUrl) {
return async(
WS.url(feedUrl). get().map(
new Function() {
public Result apply(WS.Response response) {
return ok("Feed title:" + response .asJson().findPath("title"));
}
}
)
);
}

This only applies to You are performing simple operations, such as passing the result of a WS call directly to the user. But, what if you have to perform other operations on the result?

Look at the documentation, it looks like you can do this:

Promise promise = WS.url("http://some. website.com").get();
Response response = promise.get(); // I've got the result, but I've also blocked

This is obviously not ideal Is there a way to make asynchronous calls while allowing Play to pass execution to other threads?

Take a look at https://github.com/jroper/play-promise-presentation. This is how I design a project that may have multiple promise calls, etc. System, and operate various promise responses to the content required for more complex responses, etc. I really know it very well.

The best part is – this example doesn’t feel too verbose .It reads very well and is very simple to understand.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3466 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.