Google App Engine Task Queue on GWT

前端 未结 2 503
离开以前
离开以前 2021-01-06 06:07

I\'m looking at Google App Engine\'s new task queue API for Java and I\'m having a hard time relating that to my GWT application. If I wanted to use a task queue to do some

2条回答
  •  我在风中等你
    2021-01-06 06:52

    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"));
        }
    }
    

提交回复
热议问题