A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://cloud.google.com/tasks/docs/creating-appengine-handlers below:

Create App Engine task handlers | Cloud Tasks Documentation

Skip to main content Create App Engine task handlers

Stay organized with collections Save and categorize content based on your preferences.

This page demonstrates how to create an App Engine task handler, the worker code that handles an App Engine task. The Cloud Tasks queue sends HTTP requests to your task handler. Upon successful completion of processing, the handler must send an HTTP status code between 200 and 299 back to the queue. Any other value indicates the task has failed and the queue retries the task.

Note: App Engine itself returns a 503 status code when instances are overloaded or otherwise unavailable. The Task service responds to this by slowing delivery from queues to handlers, to avoid making the problem worse. If you want to trigger a retry intentionally, use any status code other than 2xx or 503.

App Engine Task Queue requests are sent from the IP address 0.1.0.2. Also refer to the IP range for requests sent to the App Engine environment.

C# Go Java Node.js PHP Python Ruby Timeouts

App Engine tasks have specific timeouts that depend on the scaling type of the service that's running them.

For worker services running in the standard environment:

For worker services running in the flex environment: all types have a 60 minute timeout.

If your handler misses the deadline, the queue assumes the task failed and retries it.

Note: You should consider whether your handler is idempotent. Cloud Tasks is designed to provide "at least once" delivery; that is, if a task is successfully added, the queue will deliver it at least once. Note that in some rare circumstances, multiple task execution is possible, so your code must ensure that there are no harmful side-effects of repeated execution.

Requests sent to your App Engine handler by a Cloud Tasks queue have special headers, which contain task-specific information your handler might want to use.

These headers are set internally. If any of these headers are present in an external user request to your app, they are replaced by the internal ones — except for requests from logged in administrators of the application, who are allowed to set headers for testing purposes.

App Engine task requests always contain the following headers:

Header Description X-AppEngine-QueueName The name of the queue. X-AppEngine-TaskName The "short" name of the task, or, if no name was specified at creation, a unique system-generated id. This is the my-task-id value in the complete task name; for example, task_name = projects/my-project-id/locations/my-location/queues/my-queue-id/tasks/my-task-id. X-AppEngine-TaskRetryCount The number of times that the task has been retried. For the first attempt, this value is 0. This number includes attempts where the task failed due to a lack of available instances and never reached the execution phase. X-AppEngine-TaskExecutionCount The number of times that the task has executed and received a response from the handler. Since Cloud Tasks deletes the task once a successful response has been received, all previous handler responses are failures. This number does not include failures due to a lack of available instances. Note that X-AppEngine-TaskExecutionCount can be equal to X-AppEngine-TaskRetryCount if it is updated before an execution is attempted. X-AppEngine-TaskETA The schedule time of the task, specified in seconds since January 1st 1970.

If your request handler finds any of the headers listed previously, it can assume that the request is a Cloud Tasks request.

In addition, requests from Cloud Tasks might contain the following headers:

Header Description X-AppEngine-TaskPreviousResponse The HTTP response code from the previous retry. X-AppEngine-TaskRetryReason The reason for retrying the task. X-AppEngine-FailFast Indicates that a task fails immediately if an existing instance is not available. Target routing

In App Engine tasks, both the queue and the task handler run within the same Google Cloud project. Traffic is encrypted during transport and never leaves Google datacenters. You cannot explicitly set the protocol (for example, HTTP or HTTPS). The request to the handler, however, will appear to have used the HTTP protocol.

Tasks can be dispatched to secure task handlers, unsecure task handlers, and in supported runtimes, URIs restricted with login: admin. Because tasks are not run as any user, they cannot be dispatched to URIs restricted with login: required. Task dispatches also don't follow redirects.

What's next

Except 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."],[],[]]


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