|
1 | 1 | # AMQP Module |
2 | | - |
| 2 | +**For additional reference,, please review the [source](https://github.com/Codeception/Codeception/tree/master/src/Codeception/Module/AMQP)** |
3 | 3 | This module interacts with message broker software that implements |
4 | | -the Advanced Message Queuing Protocol (AMQP) standard. For example, RabbitMQ. |
| 4 | +the Advanced Message Queuing Protocol (AMQP) standard. For example, RabbitMQ (tested). |
5 | 5 | Use it to cleanup the queue between tests. |
6 | 6 |
|
| 7 | +## Status |
| 8 | +* Maintainer: **davert**, **tiger-seo** |
| 9 | +* Stability: **alpha** |
| 10 | +* Contact: codecept@davert.mail.ua |
| 11 | +* Contact: tiger.seo@gmail.com |
| 12 | + |
| 13 | +*Please review the code of non-stable modules and provide patches if you have issues.* |
| 14 | + |
7 | 15 | ## Config |
8 | 16 |
|
| 17 | +* host: localhost - host to connect |
| 18 | +* username: guest - username to connect |
| 19 | +* password: guest - password to connect |
| 20 | +* vhost: '/' - vhost to connect |
9 | 21 | * cleanup: true - defined queues will be purged before running every test. |
| 22 | +* queues: [mail, twitter] - queues to cleanup |
| 23 | + |
| 24 | +Example: |
| 25 | + |
| 26 | +modules: |
| 27 | + enabled: [AMQP] |
| 28 | + config: |
| 29 | + AMQP: |
| 30 | + host: 'localhost' |
| 31 | + port: '5672' |
| 32 | + username: 'guest' |
| 33 | + password: 'guest' |
| 34 | + vhost: '/' |
| 35 | + queues: [queue1, queue2] |
| 36 | + |
| 37 | +## Public Properties |
10 | 38 |
|
11 | | -## Other |
| 39 | +* connection - AMQPConnection - current connection |
| 40 | +* channel - AMQPChannel - current channel |
12 | 41 |
|
13 | 42 | * available since version 1.1.2 |
14 | 43 | * author tiger.seo@gmail.com |
| 44 | + * author davert |
15 | 45 |
|
16 | 46 | ## Actions |
17 | 47 |
|
18 | 48 |
|
19 | | -### cleanupAMQP |
| 49 | +### pushToExchange |
| 50 | + |
| 51 | + |
| 52 | +Sends message to exchange |
| 53 | + |
| 54 | +``` php |
| 55 | +<?php |
| 56 | +$I->pushToExchange('exchange.emails', 'thanks'); |
| 57 | +$I->pushToExchange('exchange.emails', new AMQPMessage('Thanks!')); |
| 58 | +?> |
| 59 | +``` |
| 60 | + |
| 61 | + * param $exchange |
| 62 | + * param $message string|AMQPMessage |
| 63 | + |
| 64 | + |
| 65 | +### pushToQueue |
| 66 | + |
| 67 | + |
| 68 | +Sends message to queue |
| 69 | + |
| 70 | +``` php |
| 71 | +<?php |
| 72 | +$I->pushToQueue('queue.jobs', 'create user'); |
| 73 | +$I->pushToQueue('queue.jobs', new AMQPMessage('create')); |
| 74 | +?> |
| 75 | +``` |
| 76 | + |
| 77 | + * param $queue |
| 78 | + * param $message string|AMQPMessage |
| 79 | + |
| 80 | + |
| 81 | +### seeMessageInQueue |
| 82 | + |
| 83 | + |
| 84 | +Checks if message containing text received. |
| 85 | + |
| 86 | +**This method drops message from queue** |
| 87 | +**This method will wait for message. If none is sent the script will stuck**. |
| 88 | +**Purges queue in the end** |
20 | 89 |
|
| 90 | +``` php |
| 91 | +<?php |
| 92 | +$I->pushToQueue('queue.emails', 'Hello, davert'); |
| 93 | +$I->seeMessageInQueue('queue.emails','davert'); |
| 94 | +?> |
| 95 | +``` |
21 | 96 |
|
22 | | -Cleans up queue. |
| 97 | + * param $queue |
| 98 | + * param $message |
0 commit comments