GWT Google App Engine Task Queue

I am looking at the App App Queue API for Java, and I find it difficult to associate this with my GWT application. If I would like to use the task queue to perform asynchronous processing, how can I do this using GWT.

As I see it, I need to send a server request, which will then perform a presentation in the task queue API. If I understood the task queue correctly, I would have to create another servlet to process from the task queue (whether it be a worker).

I am looking for 2 things:

  • Will it be a working servlet (i.e. extends HttpServlet )? If not, can someone give me an example of a “worker”?
  • Does it really make sense to use a task queue if I just want to send an asynchronous response for immediate execution? It seems that the GWT built-in RPC engine is enough.
+4
source share
2 answers

Yes, the worker will be a servlet that can handle the request with POST parameters. If you need an asynchronous call from the client's point of view, then RPC is enough (from the server's point of view, it is still synchronous). If you want to perform “deferred” tasks that do not speak with your client, you can use the task queue.

+6
source

Deferred.Deferable

Any plans for deferred.defer in Java?

 import static com.google.appengine.api.labs.taskqueue.TaskOptions.Builder.taskName; import java.io.IOException; import javax.servlet.ServletException; import com.newatlanta.appengine.taskqueue.Deferred; import com.newatlanta.appengine.taskqueue.Deferred.Deferrable; @SuppressWarnings("serial") public class SampleTask implements Deferrable { private String arg1; private String arg2; public SampleTask() { } public SampleTask(String arg1, String arg2) { // save information to use later this.arg1 = arg1; this.arg2 = arg2; } @Override public void doTask() throws ServletException, IOException { // TODO do work here // this is how you 'schedule' a task // doing this here is recursive; // you most likely want to call this from // a server rpc endpoint SampleTask task = new SampleTask("arg1", "arg2"); Deferred.defer(task, "queue-name", taskName("task-name")); } } 
0
source

All Articles