commit | author | age
|
2207d6
|
1 |
# Queue |
W |
2 |
|
|
3 |
|
|
4 |
|
|
5 |
Works with Queue servers. |
|
6 |
|
|
7 |
Testing with a selection of remote/local queueing services, including Amazon's SQS service |
|
8 |
Iron.io service and beanstalkd service. |
|
9 |
|
|
10 |
Supported and tested queue types are: |
|
11 |
|
|
12 |
* [Iron.io](http://iron.io/) |
|
13 |
* [Beanstalkd](http://kr.github.io/beanstalkd/) |
|
14 |
* [Amazon SQS](http://aws.amazon.com/sqs/) |
|
15 |
|
|
16 |
The following dependencies are needed for the listed queue servers: |
|
17 |
|
|
18 |
* Beanstalkd: pda/pheanstalk ~3.0 |
|
19 |
* Amazon SQS: aws/aws-sdk-php |
|
20 |
* IronMQ: iron-io/iron_mq |
|
21 |
|
|
22 |
## Status |
|
23 |
|
|
24 |
* Maintainer: **nathanmac** |
|
25 |
* Stability: |
|
26 |
- Iron.io: **stable** |
|
27 |
- Beanstalkd: **stable** |
|
28 |
- Amazon SQS: **stable** |
|
29 |
* Contact: nathan.macnamara@outlook.com |
|
30 |
|
|
31 |
## Config |
|
32 |
|
|
33 |
The configuration settings depending on which queueing service is being used, all the options are listed |
|
34 |
here. Refer to the configuration examples below to identify the configuration options required for your chosen |
|
35 |
service. |
|
36 |
|
|
37 |
* type - type of queueing server (defaults to beanstalkd). |
|
38 |
* host - hostname/ip address of the queue server or the host for the iron.io when using iron.io service. |
|
39 |
* port: 11300 - port number for the queue server. |
|
40 |
* timeout: 90 - timeout settings for connecting the queue server. |
|
41 |
* token - Iron.io access token. |
|
42 |
* project - Iron.io project ID. |
|
43 |
* key - AWS access key ID. |
|
44 |
* version - AWS version (e.g. latest) |
|
45 |
* endpoint - The full URI of the webservice. This is only required when connecting to a custom endpoint (e.g., a local version of SQS). |
|
46 |
* secret - AWS secret access key. |
|
47 |
Warning: |
|
48 |
Hard-coding your credentials can be dangerous, because it is easy to accidentally commit your credentials |
|
49 |
into an SCM repository, potentially exposing your credentials to more people than intended. |
|
50 |
It can also make it difficult to rotate credentials in the future. |
|
51 |
* profile - AWS credential profile |
|
52 |
- it should be located in ~/.aws/credentials file |
|
53 |
- eg: [default] |
|
54 |
aws_access_key_id = YOUR_AWS_ACCESS_KEY_ID |
|
55 |
aws_secret_access_key = YOUR_AWS_SECRET_ACCESS_KEY |
|
56 |
[project1] |
|
57 |
aws_access_key_id = YOUR_AWS_ACCESS_KEY_ID |
|
58 |
aws_secret_access_key = YOUR_AWS_SECRET_ACCESS_KEY |
|
59 |
- Note: Using IAM roles is the preferred technique for providing credentials |
|
60 |
to applications running on Amazon EC2 |
|
61 |
http://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/credentials.html?highlight=credentials |
|
62 |
|
|
63 |
* region - A region parameter is also required for AWS, refer to the AWS documentation for possible values list. |
|
64 |
|
|
65 |
### Example |
|
66 |
#### Example (beanstalkd) |
|
67 |
|
|
68 |
modules: |
|
69 |
enabled: [Queue] |
|
70 |
config: |
|
71 |
Queue: |
|
72 |
type: 'beanstalkd' |
|
73 |
host: '127.0.0.1' |
|
74 |
port: 11300 |
|
75 |
timeout: 120 |
|
76 |
|
|
77 |
#### Example (Iron.io) |
|
78 |
|
|
79 |
modules: |
|
80 |
enabled: [Queue] |
|
81 |
config: |
|
82 |
Queue: |
|
83 |
'type': 'iron', |
|
84 |
'host': 'mq-aws-us-east-1.iron.io', |
|
85 |
'token': 'your-token', |
|
86 |
'project': 'your-project-id' |
|
87 |
|
|
88 |
#### Example (AWS SQS) |
|
89 |
|
|
90 |
modules: |
|
91 |
enabled: [Queue] |
|
92 |
config: |
|
93 |
Queue: |
|
94 |
'type': 'aws', |
|
95 |
'key': 'your-public-key', |
|
96 |
'secret': 'your-secret-key', |
|
97 |
'region': 'us-west-2' |
|
98 |
|
|
99 |
#### Example AWS SQS using profile credentials |
|
100 |
|
|
101 |
modules: |
|
102 |
enabled: [Queue] |
|
103 |
config: |
|
104 |
Queue: |
|
105 |
'type': 'aws', |
|
106 |
'profile': 'project1', //see documentation |
|
107 |
'region': 'us-west-2' |
|
108 |
|
|
109 |
#### Example AWS SQS running on Amazon EC2 instance |
|
110 |
|
|
111 |
modules: |
|
112 |
enabled: [Queue] |
|
113 |
config: |
|
114 |
Queue: |
|
115 |
'type': 'aws', |
|
116 |
'region': 'us-west-2' |
|
117 |
|
|
118 |
|
|
119 |
## Actions |
|
120 |
|
|
121 |
### addMessageToQueue |
|
122 |
|
|
123 |
Add a message to a queue/tube |
|
124 |
|
|
125 |
```php |
|
126 |
<?php |
|
127 |
$I->addMessageToQueue('this is a messages', 'default'); |
|
128 |
?> |
|
129 |
``` |
|
130 |
|
|
131 |
* `param string` $message Message Body |
|
132 |
* `param string` $queue Queue Name |
|
133 |
|
|
134 |
|
|
135 |
### clearQueue |
|
136 |
|
|
137 |
Clear all messages of the queue/tube |
|
138 |
|
|
139 |
```php |
|
140 |
<?php |
|
141 |
$I->clearQueue('default'); |
|
142 |
?> |
|
143 |
``` |
|
144 |
|
|
145 |
* `param string` $queue Queue Name |
|
146 |
|
|
147 |
|
|
148 |
### dontSeeEmptyQueue |
|
149 |
|
|
150 |
Check if a queue/tube is NOT empty of all messages |
|
151 |
|
|
152 |
```php |
|
153 |
<?php |
|
154 |
$I->dontSeeEmptyQueue('default'); |
|
155 |
?> |
|
156 |
``` |
|
157 |
|
|
158 |
* `param string` $queue Queue Name |
|
159 |
|
|
160 |
|
|
161 |
### dontSeeQueueExists |
|
162 |
|
|
163 |
Check if a queue/tube does NOT exist on the queueing server. |
|
164 |
|
|
165 |
```php |
|
166 |
<?php |
|
167 |
$I->dontSeeQueueExists('default'); |
|
168 |
?> |
|
169 |
``` |
|
170 |
|
|
171 |
* `param string` $queue Queue Name |
|
172 |
|
|
173 |
|
|
174 |
### dontSeeQueueHasCurrentCount |
|
175 |
|
|
176 |
Check if a queue/tube does NOT have a given current number of messages |
|
177 |
|
|
178 |
```php |
|
179 |
<?php |
|
180 |
$I->dontSeeQueueHasCurrentCount('default', 10); |
|
181 |
?> |
|
182 |
``` |
|
183 |
|
|
184 |
* `param string` $queue Queue Name |
|
185 |
* `param int` $expected Number of messages expected |
|
186 |
|
|
187 |
|
|
188 |
### dontSeeQueueHasTotalCount |
|
189 |
|
|
190 |
Check if a queue/tube does NOT have a given total number of messages |
|
191 |
|
|
192 |
```php |
|
193 |
<?php |
|
194 |
$I->dontSeeQueueHasTotalCount('default', 10); |
|
195 |
?> |
|
196 |
``` |
|
197 |
|
|
198 |
* `param string` $queue Queue Name |
|
199 |
* `param int` $expected Number of messages expected |
|
200 |
|
|
201 |
|
|
202 |
### grabQueueCurrentCount |
|
203 |
|
|
204 |
Grabber method to get the current number of messages on the queue/tube (pending/ready) |
|
205 |
|
|
206 |
```php |
|
207 |
<?php |
|
208 |
$I->grabQueueCurrentCount('default'); |
|
209 |
?> |
|
210 |
``` |
|
211 |
* `param string` $queue Queue Name |
|
212 |
|
|
213 |
* `return` int Count |
|
214 |
|
|
215 |
|
|
216 |
### grabQueueTotalCount |
|
217 |
|
|
218 |
Grabber method to get the total number of messages on the queue/tube |
|
219 |
|
|
220 |
```php |
|
221 |
<?php |
|
222 |
$I->grabQueueTotalCount('default'); |
|
223 |
?> |
|
224 |
``` |
|
225 |
|
|
226 |
* `param` $queue Queue Name |
|
227 |
|
|
228 |
* `return` int Count |
|
229 |
|
|
230 |
|
|
231 |
### grabQueues |
|
232 |
|
|
233 |
Grabber method to get the list of queues/tubes on the server |
|
234 |
|
|
235 |
```php |
|
236 |
<?php |
|
237 |
$queues = $I->grabQueues(); |
|
238 |
?> |
|
239 |
``` |
|
240 |
|
|
241 |
* `return` array List of Queues/Tubes |
|
242 |
|
|
243 |
|
|
244 |
### seeEmptyQueue |
|
245 |
|
|
246 |
Check if a queue/tube is empty of all messages |
|
247 |
|
|
248 |
```php |
|
249 |
<?php |
|
250 |
$I->seeEmptyQueue('default'); |
|
251 |
?> |
|
252 |
``` |
|
253 |
|
|
254 |
* `param string` $queue Queue Name |
|
255 |
|
|
256 |
|
|
257 |
### seeQueueExists |
|
258 |
|
|
259 |
Check if a queue/tube exists on the queueing server. |
|
260 |
|
|
261 |
```php |
|
262 |
<?php |
|
263 |
$I->seeQueueExists('default'); |
|
264 |
?> |
|
265 |
``` |
|
266 |
|
|
267 |
* `param string` $queue Queue Name |
|
268 |
|
|
269 |
|
|
270 |
### seeQueueHasCurrentCount |
|
271 |
|
|
272 |
Check if a queue/tube has a given current number of messages |
|
273 |
|
|
274 |
```php |
|
275 |
<?php |
|
276 |
$I->seeQueueHasCurrentCount('default', 10); |
|
277 |
?> |
|
278 |
``` |
|
279 |
|
|
280 |
* `param string` $queue Queue Name |
|
281 |
* `param int` $expected Number of messages expected |
|
282 |
|
|
283 |
|
|
284 |
### seeQueueHasTotalCount |
|
285 |
|
|
286 |
Check if a queue/tube has a given total number of messages |
|
287 |
|
|
288 |
```php |
|
289 |
<?php |
|
290 |
$I->seeQueueHasTotalCount('default', 10); |
|
291 |
?> |
|
292 |
``` |
|
293 |
|
|
294 |
* `param string` $queue Queue Name |
|
295 |
* `param int` $expected Number of messages expected |
|
296 |
|
|
297 |
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.5/src/Codeception/Module/Queue.php">Help us to improve documentation. Edit module reference</a></div> |