Skip to content

Support Cloud Tasks backend and transactional tasks for Push Queues

Pre-release
Pre-release

Choose a tag to compare

@gajjarc gajjarc released this 07 Aug 15:06
7b3243f

What's New in this Release

This release introduces native Google Cloud Tasks backend support and Transactional Task execution for App Engine Standard Push Queues in the Python SDK (google.appengine.api.taskqueue), enabled via the APPENGINE_USE_CLOUDTASK_PUSH_QUEUE=true environment variable.

Applications using standard taskqueue APIs can now route push traffic through Cloud Tasks (using google-cloud-tasks / GAPIC tasks_v2beta3) without modifying application code.


🚀 Key Features & Enhancements

  • Cloud Tasks Push Queue Routing:

    • Automatically redirects Queue.add(), Queue.add_async(), Task.add(), and Task.add_async() to Google Cloud Tasks when APPENGINE_USE_CLOUDTASK_PUSH_QUEUE=true.
    • Supports single (create_task) and bulk task creation (batch_create_tasks).
    • Supports queue maintenance APIs: delete_tasks(), purge(), and fetch_statistics().
  • Transactional Tasks Support (Transactional Outbox Pattern):

    • Supports adding tasks inside active transactions for both NDB and DB / Datastore via Datastore staging (_AE_PendingCloudTask).
    • NDB: Uses ndb.get_context().call_on_commit(...) for immediate post-commit task dispatch.
    • DB / Datastore: Added _on_commit_callbacks to TransactionalConnection in datastore_rpc to trigger post-commit dispatch upon transaction commit.
  • Background Sweeper Middleware:

    • Added CloudTaskSweepMiddleware to intercept cron requests on /_ah/cloudtask/sweep to ensure at-least-once delivery for pending transactional tasks.
  • Task Parameter & Retry Mapping:

    • Converts countdown and eta to UTC schedule_time timestamps.
    • Maps TaskRetryOptions (retry limits, backoff intervals, max doublings) to Cloud Tasks retry configs.
    • Retains App Engine target headers, HTTP methods, and dispatch targets.
  • Error Translation:

    • Translates Cloud Tasks gRPC and REST status codes (e.g. NOT_FOUND, ALREADY_EXISTS, INVALID_ARGUMENT) into native taskqueue exceptions (UnknownQueueError, TaskAlreadyExistsError, InvalidTaskError).
  • Pull Queue Backward Compatibility:

    • Pull queues continue to route through the standard TaskQueue stub.

⚙️ How to Enable

To use Cloud Tasks as the backend for TaskQueue Push Queues, add the following environment variable to your app.yaml:

env_variables:
  APPENGINE_USE_CLOUDTASK_PUSH_QUEUE: 'true'