This page demonstrates how to programmatically create App Engine tasks and place them in Cloud Tasks queues. Using this process you can explicitly specify the service and handler that should process the task, and optionally pass task-specific data along to the handler. The Cloud Tasks service forwards the task request to the handler, but this worker is located within App Engine. So all queues that target App Engine handlers must have an App Engine app. The handlers must run in the region where the App Engine app runs. This region also serves as the LOCATION_ID
parameter for your Cloud Tasks requests. For more information, see Cloud Tasks queues with App Engine targets.
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. If you chose to specify a name for the task, Cloud Tasks can use that name to ensure task deduplication, although the necessary processing can add increased latency.
App Engine firewall rules
In the App Engine standard environment, the App Engine firewall can allow certain internal traffic to bypass the firewall. This means that if you set the default
rule to deny
, requests from certain services destined for the App Engine standard environment don't get blocked. These are all types of traffic requested in the app's own configuration, or sent from the same app. Requests that bypass firewall rules in this way also include App Engine tasks in Cloud Tasks (including App Engine Task Queues).
To allow incoming requests, the following are the IP ranges for App Engine tasks in Cloud Tasks (including App Engine Task Queues):
IP range for requests sent to the App Engine standard environment:
0.1.0.2/32
(bypasses the default firewall rule if set to deny)IP range for requests sent to the App Engine flexible environment:
0.1.0.2/32
Create tasks using the client libraries
You create tasks in the form of an HTTP request, which you can construct as you like. Using the client libraries however, as the following samples do, can help you manage details of low level communication with the server, including authenticating with Google. For adding a task to a queue, see Add a task to a Cloud Tasks queue
C#
Go
Java
Note the pom.xml
file:
Node.js
Note the package.json
file:
PHP
Note the composer.json
file:
Python
Note the requirements.txt
file:
Ruby
What's next
- Learn about creating App Engine task handlers.
- Learn more about tasks in the RPC API reference.
- Learn more about tasks in the REST API reference.