Question

I want to execute periodic background jobs on Google App Engine. Each invocation is likely to exhaust the normal time limit for normal HTTP request.

I currently intend a scheme where there is an outer servlet configured as cron job. It then invokes an inner (Java) servlet by adding it to a task queue. The inner servlet then does the background job. In essence, the outer servlet is configured declaratively (in cron.xml) and the inner servlet is configured programmatically (calls to Google Tasks API from the outer servlet). The outer servlet is essentially a "cron job which adds all the pieces [i.e. currently a single inner servlet] to a task queue".

My question is this: can I somehow combine the two servlets into a single instance that can run undisrupted for several minutes? Could one pass the required task configuration in web.xml, or similar, somehow?

Was it helpful?

Solution

A cron job servlet has 10 minute request timeout just like a taskqueue servlet, so you could easily run the code under the cron servlet. However, I would still go with the cron firing the task, as this gives you more flexibility going forward. For example, you could trigger the task servlet from anywhere in your app if you wanted to.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top