# Google Cloud Tasks V2 Client - Class Queue (2.2.0)

2.2.0 (latest) 2.1.2 2.0.2 1.15.2 1.14.6 1.13.2 1.12.2 1.11.11 Reference documentation and code samples for the Google Cloud Tasks V2 Client class Queue.

A queue is a container of related tasks. Queues are configured to manage
how those tasks are dispatched. Configurable properties include rate limits,
retry options, queue types, and others.

Generated from protobuf message `google.cloud.tasks.v2.Queue`

## Namespace

Google \\ Cloud \\ Tasks \\ V2

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ name` | `string` Caller-specified and required in [CreateQueue](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Client.CloudTasksClient#_Google_Cloud_Tasks_V2_Client_CloudTasksClient__createQueue__), after which it becomes output only. The queue name. The queue name must have the following format: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` \* \* `PROJECT_ID` can contain letters (\[A-Za-z\]), numbers (\[0-9\]), hyphens (-), colons (:), or periods (.). For more information, see [Identifying projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects) \* \* `LOCATION_ID` is the canonical ID for the queue's location. The list of available locations can be obtained by calling ListLocations. For more information, see <https://cloud.google.com/about/locations/>. \* \* `QUEUE_ID` can contain letters (\[A-Za-z\]), numbers (\[0-9\]), or hyphens (-). The maximum length is 100 characters. |
| `↳ app_engine_routing_override` | `https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.AppEngineRouting` Overrides for [task-level app_engine_routing](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.AppEngineHttpRequest#_Google_Cloud_Tasks_V2_AppEngineHttpRequest__getAppEngineRouting__). These settings apply only to [App Engine tasks](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.AppEngineHttpRequest) in this queue. [Http tasks](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.HttpRequest) are not affected. If set, `app_engine_routing_override` is used for all [App Engine tasks](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.AppEngineHttpRequest) in the queue, no matter what the setting is for the [task-level app_engine_routing](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.AppEngineHttpRequest#_Google_Cloud_Tasks_V2_AppEngineHttpRequest__getAppEngineRouting__). |
| `↳ rate_limits` | `https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.RateLimits` Rate limits for task dispatches. [rate_limits](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRateLimits__) and [retry_config](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRetryConfig__) are related because they both control task attempts. However they control task attempts in different ways: \* \* [rate_limits](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRateLimits__) controls the total rate of dispatches from a queue (i.e. all traffic dispatched from the queue, regardless of whether the dispatch is from a first attempt or a retry). \* \* [retry_config](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRetryConfig__) controls what happens to particular a task after its first attempt fails. That is, [retry_config](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRetryConfig__) controls task retries (the second attempt, third attempt, etc). The queue's actual dispatch rate is the result of: \* \* Number of tasks in the queue \* \* User-specified throttling: [rate_limits](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRateLimits__), [retry_config](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRetryConfig__), and the [queue's state](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getState__). \* \* System throttling due to `429` (Too Many Requests) or `503` (Service Unavailable) responses from the worker, high error rates, or to smooth sudden large traffic spikes. |
| `↳ retry_config` | `https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.RetryConfig` Settings that determine the retry behavior. \* \* For tasks created using Cloud Tasks: the queue-level retry settings apply to all tasks in the queue that were created using Cloud Tasks. Retry settings cannot be set on individual tasks. \* \* For tasks created using the App Engine SDK: the queue-level retry settings apply to all tasks in the queue which do not have retry settings explicitly set on the task and were created by the App Engine SDK. See [App Engine documentation](https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/retrying-tasks). |
| `↳ state` | `int` Output only. The state of the queue. `state` can only be changed by calling [PauseQueue](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Client.CloudTasksClient#_Google_Cloud_Tasks_V2_Client_CloudTasksClient__pauseQueue__), [ResumeQueue](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Client.CloudTasksClient#_Google_Cloud_Tasks_V2_Client_CloudTasksClient__resumeQueue__), or uploading [queue.yaml/xml](https://cloud.google.com/appengine/docs/python/config/queueref). [UpdateQueue](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Client.CloudTasksClient#_Google_Cloud_Tasks_V2_Client_CloudTasksClient__updateQueue__) cannot be used to change `state`. |
| `↳ purge_time` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp` Output only. The last time this queue was purged. All tasks that were [created](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Task#_Google_Cloud_Tasks_V2_Task__getCreateTime__) before this time were purged. A queue can be purged using [PurgeQueue](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Client.CloudTasksClient#_Google_Cloud_Tasks_V2_Client_CloudTasksClient__purgeQueue__), the [App Engine Task Queue SDK, or the Cloud Console](https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/deleting-tasks-and-queues#purging_all_tasks_from_a_queue). Purge time will be truncated to the nearest microsecond. Purge time will be unset if the queue has never been purged. |
| `↳ stackdriver_logging_config` | `https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.StackdriverLoggingConfig` Configuration options for writing logs to [Stackdriver Logging](https://cloud.google.com/logging/docs/). If this field is unset, then no logs are written. |

### getName

Caller-specified and required in
[CreateQueue](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Client.CloudTasksClient#_Google_Cloud_Tasks_V2_Client_CloudTasksClient__createQueue__), after which it
becomes output only.

The queue name.
The queue name must have the following format:
`projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`

- `PROJECT_ID` can contain letters (\[A-Za-z\]), numbers (\[0-9\]), hyphens (-), colons (:), or periods (.). For more information, see [Identifying
  projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
- `LOCATION_ID` is the canonical ID for the queue's location. The list of available locations can be obtained by calling ListLocations. For more information, see <https://cloud.google.com/about/locations/>.
- `QUEUE_ID` can contain letters (\[A-Za-z\]), numbers (\[0-9\]), or hyphens (-). The maximum length is 100 characters.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setName

Caller-specified and required in
[CreateQueue](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Client.CloudTasksClient#_Google_Cloud_Tasks_V2_Client_CloudTasksClient__createQueue__), after which it
becomes output only.

The queue name.
The queue name must have the following format:
`projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`

- `PROJECT_ID` can contain letters (\[A-Za-z\]), numbers (\[0-9\]), hyphens (-), colons (:), or periods (.). For more information, see [Identifying
  projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
- `LOCATION_ID` is the canonical ID for the queue's location. The list of available locations can be obtained by calling ListLocations. For more information, see <https://cloud.google.com/about/locations/>.
- `QUEUE_ID` can contain letters (\[A-Za-z\]), numbers (\[0-9\]), or hyphens (-). The maximum length is 100 characters.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getAppEngineRoutingOverride

Overrides for
[task-level
app_engine_routing](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.AppEngineHttpRequest#_Google_Cloud_Tasks_V2_AppEngineHttpRequest__getAppEngineRouting__).

These settings apply only to
[App Engine tasks](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.AppEngineHttpRequest) in this
queue. [Http tasks](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.HttpRequest) are not affected.
If set, `app_engine_routing_override` is used for all
[App Engine tasks](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.AppEngineHttpRequest) in the
queue, no matter what the setting is for the [task-level
app_engine_routing](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.AppEngineHttpRequest#_Google_Cloud_Tasks_V2_AppEngineHttpRequest__getAppEngineRouting__).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.AppEngineRouting|null` |   |

### hasAppEngineRoutingOverride

### clearAppEngineRoutingOverride

### setAppEngineRoutingOverride

Overrides for
[task-level
app_engine_routing](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.AppEngineHttpRequest#_Google_Cloud_Tasks_V2_AppEngineHttpRequest__getAppEngineRouting__).

These settings apply only to
[App Engine tasks](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.AppEngineHttpRequest) in this
queue. [Http tasks](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.HttpRequest) are not affected.
If set, `app_engine_routing_override` is used for all
[App Engine tasks](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.AppEngineHttpRequest) in the
queue, no matter what the setting is for the [task-level
app_engine_routing](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.AppEngineHttpRequest#_Google_Cloud_Tasks_V2_AppEngineHttpRequest__getAppEngineRouting__).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.AppEngineRouting` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getRateLimits

Rate limits for task dispatches.

[rate_limits](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRateLimits__) and
[retry_config](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRetryConfig__) are related
because they both control task attempts. However they control task attempts
in different ways:

- [rate_limits](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRateLimits__) controls the total rate of dispatches from a queue (i.e. all traffic dispatched from the queue, regardless of whether the dispatch is from a first attempt or a retry).
- [retry_config](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRetryConfig__) controls what happens to particular a task after its first attempt fails. That is, [retry_config](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRetryConfig__) controls task retries (the second attempt, third attempt, etc). The queue's actual dispatch rate is the result of:
- Number of tasks in the queue
- User-specified throttling: [rate_limits](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRateLimits__), [retry_config](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRetryConfig__), and the [queue's state](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getState__).
- System throttling due to `429` (Too Many Requests) or `503` (Service Unavailable) responses from the worker, high error rates, or to smooth sudden large traffic spikes.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.RateLimits|null` |   |

### hasRateLimits

### clearRateLimits

### setRateLimits

Rate limits for task dispatches.

[rate_limits](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRateLimits__) and
[retry_config](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRetryConfig__) are related
because they both control task attempts. However they control task attempts
in different ways:

- [rate_limits](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRateLimits__) controls the total rate of dispatches from a queue (i.e. all traffic dispatched from the queue, regardless of whether the dispatch is from a first attempt or a retry).
- [retry_config](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRetryConfig__) controls what happens to particular a task after its first attempt fails. That is, [retry_config](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRetryConfig__) controls task retries (the second attempt, third attempt, etc). The queue's actual dispatch rate is the result of:
- Number of tasks in the queue
- User-specified throttling: [rate_limits](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRateLimits__), [retry_config](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getRetryConfig__), and the [queue's state](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue#_Google_Cloud_Tasks_V2_Queue__getState__).
- System throttling due to `429` (Too Many Requests) or `503` (Service Unavailable) responses from the worker, high error rates, or to smooth sudden large traffic spikes.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.RateLimits` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getRetryConfig

Settings that determine the retry behavior.

- For tasks created using Cloud Tasks: the queue-level retry settings apply to all tasks in the queue that were created using Cloud Tasks. Retry settings cannot be set on individual tasks.
- For tasks created using the App Engine SDK: the queue-level retry settings apply to all tasks in the queue which do not have retry settings explicitly set on the task and were created by the App Engine SDK. See [App Engine
  documentation](https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/retrying-tasks).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.RetryConfig|null` |   |

### hasRetryConfig

### clearRetryConfig

### setRetryConfig

Settings that determine the retry behavior.

- For tasks created using Cloud Tasks: the queue-level retry settings apply to all tasks in the queue that were created using Cloud Tasks. Retry settings cannot be set on individual tasks.
- For tasks created using the App Engine SDK: the queue-level retry settings apply to all tasks in the queue which do not have retry settings explicitly set on the task and were created by the App Engine SDK. See [App Engine
  documentation](https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/retrying-tasks).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.RetryConfig` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getState

Output only. The state of the queue.

`state` can only be changed by calling
[PauseQueue](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Client.CloudTasksClient#_Google_Cloud_Tasks_V2_Client_CloudTasksClient__pauseQueue__),
[ResumeQueue](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Client.CloudTasksClient#_Google_Cloud_Tasks_V2_Client_CloudTasksClient__resumeQueue__), or uploading
[queue.yaml/xml](https://cloud.google.com/appengine/docs/python/config/queueref).
[UpdateQueue](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Client.CloudTasksClient#_Google_Cloud_Tasks_V2_Client_CloudTasksClient__updateQueue__) cannot be used
to change `state`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | Enum of type [State](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue.State). |

### setState

Output only. The state of the queue.

`state` can only be changed by calling
[PauseQueue](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Client.CloudTasksClient#_Google_Cloud_Tasks_V2_Client_CloudTasksClient__pauseQueue__),
[ResumeQueue](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Client.CloudTasksClient#_Google_Cloud_Tasks_V2_Client_CloudTasksClient__resumeQueue__), or uploading
[queue.yaml/xml](https://cloud.google.com/appengine/docs/python/config/queueref).
[UpdateQueue](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Client.CloudTasksClient#_Google_Cloud_Tasks_V2_Client_CloudTasksClient__updateQueue__) cannot be used
to change `state`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` Enum of type [State](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Queue.State). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getPurgeTime

Output only. The last time this queue was purged.

All tasks that were [created](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Task#_Google_Cloud_Tasks_V2_Task__getCreateTime__)
before this time were purged.
A queue can be purged using
[PurgeQueue](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Client.CloudTasksClient#_Google_Cloud_Tasks_V2_Client_CloudTasksClient__purgeQueue__), the [App Engine
Task Queue SDK, or the Cloud
Console](https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/deleting-tasks-and-queues#purging_all_tasks_from_a_queue).
Purge time will be truncated to the nearest microsecond. Purge
time will be unset if the queue has never been purged.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp|null` |   |

### hasPurgeTime

### clearPurgeTime

### setPurgeTime

Output only. The last time this queue was purged.

All tasks that were [created](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Task#_Google_Cloud_Tasks_V2_Task__getCreateTime__)
before this time were purged.
A queue can be purged using
[PurgeQueue](https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.Client.CloudTasksClient#_Google_Cloud_Tasks_V2_Client_CloudTasksClient__purgeQueue__), the [App Engine
Task Queue SDK, or the Cloud
Console](https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/deleting-tasks-and-queues#purging_all_tasks_from_a_queue).
Purge time will be truncated to the nearest microsecond. Purge
time will be unset if the queue has never been purged.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getStackdriverLoggingConfig

Configuration options for writing logs to
[Stackdriver Logging](https://cloud.google.com/logging/docs/). If this
field is unset, then no logs are written.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.StackdriverLoggingConfig|null` |   |

### hasStackdriverLoggingConfig

### clearStackdriverLoggingConfig

### setStackdriverLoggingConfig

Configuration options for writing logs to
[Stackdriver Logging](https://cloud.google.com/logging/docs/). If this
field is unset, then no logs are written.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-tasks/latest/V2.StackdriverLoggingConfig` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |