Stay organized with collections Save and categorize content based on your preferences.
This page describes how to create tasks and place them in push queues. When you want to process a task, you must create a new task object and place it on a queue. You can explicitly specify the service and handler that process the task, and optionally pass task-specific data along to the handler. You can also fine-tune the configuration for the task, like scheduling a time in the future when it should be executed or limiting the number of times you want the task to be retried if it fails.
This API is supported for first-generation runtimes and can be used when upgrading to corresponding second-generation runtimes. If you are updating to the App Engine runtime, refer to the Upgrade to second-generation runtimes page to learn about your migration options for legacy bundled services. Creating a new task Specifying the worker serviceWhen a task is popped off its queue, the Task Queue service sends it on to a worker service. Every task has a target and a url, which determine what service and handler will ultimately perform the task.
target
The target specifies the service that will receive the HTTP request to perform the task. It is a string that specifies a service/version/instance in any one of the canonical forms. The most often-used forms are:
service
version.service
instance.version.service
The target string is prepended to the domain name of your app. There are three ways to set the target for a task:
Declare the target when you construct the task.
Include a target
directive when you define a queue in the queue.yaml
, as in the definition of queue-blue
. All tasks added to a queue with a target
will use that target, even if a different target was assigned to the task at construction time.
If no target is specified according to either of the previous two methods, then the task's target is the version of the service that enqueues it. Note that if you enqueue a task from the default service and version in this manner, and the default version changes before the task executes, it will run in the new default version.
url
The url
selects one of the handlers in the target service, which will perform the task.
The url
should match one of the handler URL patterns in the target service. The url
can include query parameters if the method specified in the task is GET
or PULL
. If no url
is specified the default URL /_ah/queue/[QUEUE_NAME]
is used, where [QUEUE_NAME]
is the name of the task's queue.
You can pass data to the handler as query parameters in the task's URL, but only if the method specified in the task is GET
or PULL
.
When you create a new task, App Engine assigns the task a unique name by default. However, you can assign your own name to a task by using the name
parameter. An advantage of assigning your own task names is that named tasks are de-duplicated, which means you can use task names to guarantee that a task is only added once. De-duplication continues for 9 days after the task is completed or deleted.
Note that de-duplication logic introduces significant performance overhead, resulting in increased latencies and potentially increased error rates associated with named tasks. These costs can be magnified significantly if task names are sequential, such as with timestamps. So, if you assign your own names, we recommend using a well-distributed prefix for task names, such as a hash of the contents.
If you assign your own names to tasks, note that the maximum name length is 500 characters, and the name can contain uppercase and lowercase letters, numbers underscores, and hyphens.
What's nextExcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["Tasks are created as objects and placed on queues for processing, with the option to specify the service and handler responsible for their execution."],["The `target` parameter designates the specific service, version, or instance that will process the task, and it can be set during task creation, within the queue definition, or default to the service enqueuing the task."],["The `url` parameter within a task specifies the handler in the target service that will process it and can include query parameters for `GET` or `PULL` methods, defaulting to `/_ah/queue/[QUEUE_NAME]` if not specified."],["While App Engine assigns unique names by default, you can provide custom task names to enable de-duplication, ensuring a task is only added once, although this introduces performance overhead and latency."],["Data can be passed to the handler via query parameters within the task's URL if the method is `GET` or `PULL`."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4