To use deferred, you first have to define a class that contains the code you want to run:
class MyDeferred implements DeferredTask { @Override public void run() { // Do something interesting } }; Just like any other serializable class, you can have locals that store relevant information about the task. Then, to run the task, instantiate an instance of your class and pass it to the task queue API:
MyDeferred task = new MyDeferred(); // Set instance variables etc as you wish Queue queue = QueueFactory.getDefaultQueue(); queue.add(withPayload(task)); You can even use anonymous inner classes for your tasks, but beware of the caveats described in the note here.
Read full article from google app engine - Java GAE DeferredTask example? - Stack Overflow
No comments:
Post a Comment