1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
## 1. Introduction
A Queue is an entity that holds messages. Ideally, a queue is created per work type. For example, if you want to
compress files, you would create a queue dedicated to this job. Any application that reads from this queue would only
compress files.
## 2. Setup
```php
$service = $client->queuesService('cloudQueues', 'ORD');
```
## 3. Client IDs
With most of Marconi's operation, you must specify a __Client ID__ which will be used as a unique identifier for the
process accessing this Queue. This is basically a UUID that must be unique to each client accessing the API - it can be
an arbitrary string.
```php
$service->setClientId();
echo $service->getClientId();
```
If you call `setClientId` without any parameters, a UUID is automatically generated for you.
## 4. List queues
### 4.1 Description
This operation lists queues for the project. The queues are sorted alphabetically by name.
### 4.2 Parameters
|Name|Style|Type|Description|
|----|-----|----|-----------|
|marker|Query|String|Specifies the name of the last queue received in a previous request, or none to get the first page
of results. Optional.|
|limit|Query|Integer|Specifies the number of queues to return. The default value for the number of queues returned is
10. If you do not specify this parameter, the default number of queues is returned. Optional.|
|detailed|Query|Boolean|Determines whether queue metadata is included in the response. The default value for this
parameter is false, which excludes the metadata. Optional.|
|----|-----|----|-----------|
### 4.3 Code sample
```php
$queues = $service->listQueues();
while ($queue = $queues->next()) {
echo $queue->getName() . PHP_EOL;
}
```
## 5. Create queue
### 5.1 Description
This operation creates a new queue.
### 5.2 Parameters
A string representation of the name for your new Queue. The name must not exceed 64 bytes in length, and it is limited
to US-ASCII letters, digits, underscores, and hyphens.
### 5.3 Code sample
```php
$queue = $service->createQueue('new_queue');
```
## 6. Retrieve queue
### 6.1 Description
Returns a `Queue` object for use.
### 6.2 Parameters
Queue name.
### 6.3 Code sample
```php
$queue = $service->getQueue('new_queue');
```
## 7. Check queue existence
### 7.1 Description
This operation verifies whether the specified queue exists by returning `TRUE` or `FALSE`.
### 7.2 Parameters
### 7.3 Code sample
```php
if ($service->hasQueue('new_queue')) {
// do something
}
```
## 8. Update queue metadata (permanently to the API)
### 4.1 Description
This operation replaces any existing metadata document in its entirety. Ensure that you do not accidentally overwrite
existing metadata that you want to retain. If you want to _append_ metadata, ensure you merge a new array to the
existing values.
### 4.2 Parameters
Hash of key pairs.
### 4.3 Code sample
```php
$queue->saveMetadata(array(
'foo' => 'bar'
));
```
## 9. Retrieve the queue metadata (fresh from the API)
### 4.1 Description
This operation returns metadata, such as message TTL, for the queue.
### 4.2 Parameters
None.
### 4.3 Code sample
```php
$metadata = $queue->retrieveMetadata();
print_r($metadata->toArray());
```
## 10. Get queue stats
### 4.1 Description
This operation returns queue statistics, including how many messages are in the queue, categorized by status.
### 4.2 Parameters
None.
### 4.3 Code sample
```php
$queue->getStats();
```
|