The Java deferred library is still not in the GAE SDK and that's why you can't find any Official documentation.
This feature request is fixed since March 2011 and you can now use the deferred library straight from the Sdk
You could use the Vince Bonfanti deferred library that is available here.
The library usage is fairly simple and it is well explained in the doc:
1) The deferred task handler (servlet) needs to be configured
within web.xml
.
Note that the init-param must match the actual
url-pattern:
<servlet>
<servlet-name>Deferred</servlet-name>
<servlet-class>com.newatlanta.appengine.taskqueue.Deferred</servlet-class>
<init-param>
<param-name>url-pattern</param-name>
<param-value>/worker/deferred</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Deferred</servlet-name>
<url-pattern>/worker/deferred</url-pattern>
</servlet-mapping>
2) The "deferred" queue needs to be configured within queue.xml
(use
whatever rate you want).
If you use the optional queue name in the defer()
method, create
queues with the appropriate names.
<queue>
<name>deferred</name>
<rate>10/s</rate>
</queue>
3) Create a class that implements the
com.newatlanta.appengine.taskqueue.Deferred.Deferrable interface
;
the doTask
method of this class is where you implement your task
logic.
4) Invoke the Deferred.defer
method to queue up your task:
DeferredTask task = new DeferredTask(); // implements Deferrable
Deferred.defer( task );
If the task size exceeds 10KB, the task options are stored within a
datastore entity, which is deleted when the task is executed.
Your doTask
method can throw a PermanentTaskFailure
exception to halt
retries; any other exceptions cause the task to be retried.
Couple of bonus links:
- Feature request here.
- Google groups thread here.
- Github Fork