queue.xml Reference

Applications using the App Engine SDK to manage task queues define these queues using a configuration file called queue.xml. For Java apps, this file is stored in the application's WEB-INF directory. You can use queue.xml to configure both push queues and pull queues. This configuration file is optional for push queues, which have a default queue. Pull queues must be specifically configured in queue.xml.

Example

The following a basic example that defines a named queue and overrides the default processing rate:

<queue-entries>
  <queue>
    <name>my-push-queue</name>
    <rate>1/s</rate>
  </queue>
</queue-entries>

The following is a more complex example of a queue.xml configuration that demonstrates setting up the number of task tries and modifying the default processing rate.

<queue-entries>
  <queue>
    <name>fooqueue</name>
    <rate>1/s</rate>
    <retry-parameters>
      <task-retry-limit>7</task-retry-limit>
      <task-age-limit>2d</task-age-limit>
    </retry-parameters>
  </queue>
  <queue>
    <name>barqueue</name>
    <rate>1/s</rate>
    <retry-parameters>
      <min-backoff-seconds>10</min-backoff-seconds>
      <max-backoff-seconds>200</max-backoff-seconds>
      <max-doublings>0</max-doublings>
    </retry-parameters>
  </queue>
  <queue>
    <name>bazqueue</name>
    <rate>1/s</rate>
    <retry-parameters>
      <min-backoff-seconds>10</min-backoff-seconds>
      <max-backoff-seconds>200</max-backoff-seconds>
      <max-doublings>3</max-doublings>
    </retry-parameters>
  </queue>
</queue-entries>

Syntax

The queue.xml file is an XML file whose root element is <queue-entries>. This directive contains zero or more named queues specified within <queue> elements. Each queue definition can specify the following elements:

Element Description
<bucket-size> (push queues)

Optional. A task queue uses the token bucket algorithm to control the rate of task execution. Each named queue has a token bucket that holds tokens, up to the maximum specified by the bucket_size value. Each time your application executes a task, a token is removed from the bucket. You continue processing tasks in the queue until the queue's bucket runs out of tokens. App Engine refills the bucket with new tokens continuously based on the rate that you specified for the queue.

The bucket size limits how fast the queue is processed when many tasks are in the queue and the rate is high. The maximum value for bucket size is 500. This allows you to have a high rate so processing starts shortly after a task is enqueued, but still limit resource usage when many tasks are enqueued in a short period of time.

If you don't specify bucket_size for a queue, the default value is 5. We recommend that you set this to a larger value because the default size might be too small for many use cases: the recommended size is the processing rate divided by 5 (rate/5).

<max-concurrent-requests> (push queues)

Optional. Sets the maximum number of tasks that can be executed simultaneously from the specified queue. The value is an integer. By default, the limit is 1000 tasks per queue. The upper recommended limit is 5000 tasks per queue. Note that queues may slowly ramp up when they are first created or if they have been idle for a while.

Restricting the number of concurrent tasks gives you more control over the queue's rate of execution and can prevent too many tasks from running at once. It can also prevent datastore contention and make resources available for other queues or online processing.

<mode>

Optional. Identifies the queue mode. This setting defaults to push, which identifies a queue as a push queue. If you wish to use pull queues, set the mode to pull.

<name>

Required. The name of the queue. This is the name you specify when you call QueueFactory.getQueue().

A queue name can contain uppercase and lowercase letters, numbers, and hyphens. The maximum length for a queue name is 100 characters.

All apps have a push queue named default. This queue has a preset rate of 5 tasks per second, but you can change this rate by defining a default queue in queue.xml. If you do not configure a default queue in queue.xml, the default queue doesn't display in the Google Cloud Platform Console until the first time it is used. You can customize the settings for this queue by defining a queue named default.

<rate> (push queues)

Required. How often tasks are processed on this queue. The value is a number followed by a slash and a unit of time, where the unit is s for seconds, m for minutes, h for hours, or d for days. For example, the value 5/m says tasks will be processed at a rate of 5 times per minute. The maximum value for rate is 500/s.

If the number is 0 (such as 0/s), the queue is considered "paused," and no tasks are processed.

<retry-parameters>

Optional. Configures retry attempts for failed tasks in push queues. This addition allows you to specify the maximum number of times to retry failed tasks in a specific queue. You can also set a time limit for retry attempts and control the interval between attempts.

The retry parameters can contain the following subelements:

<task-retry-limit>
This is actually an overall limit on the maximum number of attempts for a task. If 0 or 1 is specified and the task fails, the task is not retried at all. If it is specified with task_age_limit, the task is retried until both limits are reached. If this parameter is unspecified, the task is retried indefinitely.
<task-age-limit> (push queues)
The time limit for retrying a failed task, measured from when the task was first run. The value is a number followed by a unit of time, where the unit is s for seconds, m for minutes, h for hours, or d for days. For example, the value 5d specifies a limit of five days after the task's first execution attempt. If this parameter is unspecified, the task is retried indefinitely. If specified with task_retry_limit, App Engine retries the task until both limits are reached.
<min-backoff-seconds> (push queues)
The minimum number of seconds to wait before retrying a task after it fails. The default value is 0.1.
<max-backoff-seconds> (push queues)
The maximum number of seconds to wait before retrying a task after it fails. The default value is 3600.
<max-doublings> (push queues)
The maximum number of times that the interval between failed task retries will be doubled before the increase becomes constant. The constant is: 2**max_doublings * min_backoff_seconds. The default value is 16.
<target> (push queues)

Optional. A string naming a service/version, a frontend version, or a backend, on which to execute all of the tasks enqueued onto this queue. The default value is the empty string.

The string is prepended to the domain name of your app when constructing the HTTP request for a task. For example, if your app ID is my-app and you set the target to my-version.my-service, the URL hostname will be set to my-version.my-service.my-app.appspot.com.

If target is unspecified, then tasks are invoked on the same version of the application where they were enqueued. So, if you enqueued a task from the default application version without specifying a target on the queue, the task is invoked in the default application version. Note that if the default application version changes between the time that the task is enqueued and the time that it executes, then the task will run in the new default version.

If you are using services along with a dispatch file, your task's HTTP request might be intercepted and re-routed to another service.

The following elements can be specified for all queues within an app, set inside the <queue-entries> root element:

Element Description
<total-storage-limit>

Optional. A string that overrides the default quota storage limit that is available for taskqueue storage (100M). For example:

<queue-entries>
  <total-storage-limit>1.2G</total-storage-limit>
  <queue>
    <name>fooqueue</name>
  </queue>
</queue-entries>

This quota is part of the application's total storage quota (including the datastore and blobstore quota).

If no suffix is specified, the number that you specify is interpreted as bytes. The following suffixes are supported:

  • B (bytes)
  • K (kilobytes)
  • M (megabytes)
  • G (gigabytes)
  • T (terabytes)

If <total-storage-limit> exceeds the total disk storage that is available to an application, the limit is clamped.

Deploying the queue configuration file

The queue.xml file should reside in the WEB-INF directory of the default service.

To deploy the queue configuration file without otherwise altering the currently serving version, use the command:

appcfg.sh update_queues <application directory>

replacing <application directory> with the path to your application main directory.

Deleting queues

To delete a queue:

  1. Remove the queue definition from your queue.xml file.

  2. Upload the change to your queue.xml file.

    [PATH_TO_APP_ENGINE_SDK]\bin\appcfg.sh update_queues [YOUR_APP_DIR]
    

    or on Windows:

    [PATH_TO_APP_ENGINE_SDK]\bin\appcfg.cmd update_queues [YOUR_APP_DIR]
    

  3. Delete the queue in the GCP Console, select the queue and click Delete queue:

    Go to the Task queues page

If you delete a queue from the GCP Console, you must wait 7 days before recreating with the same name.

Was this page helpful? Let us know how we did:

Send feedback about...

App Engine standard environment for Java