I\'m a bit confused by the documentation for Java DeferredTask. I\'ve read the Python documentation here: http://code.google.com/appengine/articles/deferred.html but I\'m un
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.