Skip to content

Commit ba49b6c

Browse files
committed
[magento] Add basic docs for enqueue magento extension.
1 parent 58aec46 commit ba49b6c

5 files changed

Lines changed: 235 additions & 0 deletions

File tree

docs/bundle/cli_commands.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Cli commands
22

3+
The EnqueueBundle provides several commands.
4+
The most useful one `enqueue:consume` connects to the broker and process the messages.
5+
Other commands could be useful during debugging (like `enqueue:topics`) or deployment (like `enqueue:setup-broker`).
6+
37
* [enqueue:consume](#enqueueconsume)
48
* [enqueue:produce](#enqueueproduce)
59
* [enqueue:setup-broker](#enqueuesetup-broker)
82.4 KB
Loading

docs/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
- [Production settings](bundle/production_settings.md)
3232
- [Debuging](bundle/debuging.md)
3333
- [Functional testing](bundle/functional_testing.md)
34+
* Magento
35+
- [Quick tour](magento/quick_tour.md)
36+
- [Cli commands](magento/cli_commands.md)
3437
* Development
3538
- [Contribution](contribution.md)
3639

docs/magento/cli_commands.md

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# Cli commands
2+
3+
The enqueue Magento extension provides several commands.
4+
The most useful one `enqueue:consume` connects to the broker and process the messages.
5+
Other commands could be useful during debugging (like `enqueue:topics`) or deployment (like `enqueue:setup-broker`).
6+
7+
* [enqueue:consume](#enqueueconsume)
8+
* [enqueue:produce](#enqueueproduce)
9+
* [enqueue:setup-broker](#enqueuesetup-broker)
10+
* [enqueue:queues](#enqueuequeues)
11+
* [enqueue:topics](#enqueuetopics)
12+
13+
## enqueue:consume
14+
15+
```
16+
php shell/enqueue.php enqueue:consume --help
17+
Usage:
18+
enqueue:consume [options] [--] [<client-queue-names>]...
19+
enq:c
20+
21+
Arguments:
22+
client-queue-names Queues to consume messages from
23+
24+
Options:
25+
--message-limit=MESSAGE-LIMIT Consume n messages and exit
26+
--time-limit=TIME-LIMIT Consume messages during this time
27+
--memory-limit=MEMORY-LIMIT Consume messages until process reaches this memory limit in MB
28+
--setup-broker Creates queues, topics, exchanges, binding etc on broker side.
29+
-h, --help Display this help message
30+
-q, --quiet Do not output any message
31+
-V, --version Display this application version
32+
--ansi Force ANSI output
33+
--no-ansi Disable ANSI output
34+
-n, --no-interaction Do not ask any interactive question
35+
-e, --env=ENV The environment name [default: "dev"]
36+
--no-debug Switches off debug mode
37+
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
38+
39+
Help:
40+
A client's worker that processes messages. By default it connects to default queue. It select an appropriate message processor based on a message headers
41+
```
42+
43+
## enqueue:produce
44+
45+
```
46+
php shell/enqueue.php enqueue:produce --help
47+
Usage:
48+
enqueue:produce <topic> <message>
49+
enq:p
50+
51+
Arguments:
52+
topic A topic to send message to
53+
message A message to send
54+
55+
Options:
56+
-h, --help Display this help message
57+
-q, --quiet Do not output any message
58+
-V, --version Display this application version
59+
--ansi Force ANSI output
60+
--no-ansi Disable ANSI output
61+
-n, --no-interaction Do not ask any interactive question
62+
-e, --env=ENV The environment name [default: "dev"]
63+
--no-debug Switches off debug mode
64+
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
65+
66+
Help:
67+
A command to send a message to topic
68+
```
69+
70+
## enqueue:setup-broker
71+
72+
```
73+
php shell/enqueue.php enqueue:setup-broker --help
74+
Usage:
75+
enqueue:setup-broker
76+
enq:sb
77+
78+
Options:
79+
-h, --help Display this help message
80+
-q, --quiet Do not output any message
81+
-V, --version Display this application version
82+
--ansi Force ANSI output
83+
--no-ansi Disable ANSI output
84+
-n, --no-interaction Do not ask any interactive question
85+
-e, --env=ENV The environment name [default: "dev"]
86+
--no-debug Switches off debug mode
87+
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
88+
89+
Help:
90+
Creates all required queues
91+
```
92+
93+
## enqueue:queues
94+
95+
```
96+
/bin/console enqueue:queues --help
97+
Usage:
98+
enqueue:queues
99+
enq:m:q
100+
debug:enqueue:queues
101+
102+
Options:
103+
-h, --help Display this help message
104+
-q, --quiet Do not output any message
105+
-V, --version Display this application version
106+
--ansi Force ANSI output
107+
--no-ansi Disable ANSI output
108+
-n, --no-interaction Do not ask any interactive question
109+
-e, --env=ENV The environment name [default: "dev"]
110+
--no-debug Switches off debug mode
111+
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
112+
113+
Help:
114+
A command shows all available queues and some information about them.
115+
```
116+
117+
## enqueue:topics
118+
119+
```
120+
php shell/enqueue.php enqueue:topics --help
121+
Usage:
122+
enqueue:topics
123+
enq:m:t
124+
debug:enqueue:topics
125+
126+
Options:
127+
-h, --help Display this help message
128+
-q, --quiet Do not output any message
129+
-V, --version Display this application version
130+
--ansi Force ANSI output
131+
--no-ansi Disable ANSI output
132+
-n, --no-interaction Do not ask any interactive question
133+
-e, --env=ENV The environment name [default: "dev"]
134+
--no-debug Switches off debug mode
135+
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
136+
137+
Help:
138+
A command shows all available topics and some information about them.
139+
```
140+
141+
[back to index](../index.md)
142+

docs/magento/quick_tour.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Magento Enqueue. Quick tour
2+
3+
## Installation
4+
5+
We use [composer](https://getcomposer.org/) and [cotya/magento-composer-installer](https://github.com/Cotya/magento-composer-installer) plugin to install magento-enqueue.
6+
7+
To install libraries run the commands in the application root directory.
8+
9+
```bash
10+
composer require "magento-hackathon/magento-composer-installer:~3.0"
11+
composer require "enqueue/magento-enqueue:*@dev" "enqueue/amqp-ext"
12+
```
13+
14+
## Configuration
15+
16+
At this stage we have configure the Enqueue extension in Magento backend.
17+
The config is here: System -> Configuration -> Enqueue Message Queue.
18+
Here's the example of Amqp transport that connects to RabbitMQ broker on localhost:
19+
20+
21+
![Сonfiguration](../images/magento_enqueue_configu)
22+
23+
## Publish Message
24+
25+
To send a message you have to take enqueue helper and call `send` method.
26+
27+
```php
28+
<?php
29+
30+
Mage::helper('enqueue')->send('a_topic', 'aMessage');
31+
```
32+
33+
## Message Consumption
34+
35+
I assume you have `acme` Magento module properly created, configured and registered.
36+
To consume messages you have to define a processor class first:
37+
38+
```php
39+
<?php
40+
// app/code/local/Acme/Module/Helper/Async/Foo.php
41+
42+
use Enqueue\Psr\PsrContext;
43+
use Enqueue\Psr\PsrMessage;
44+
use Enqueue\Psr\PsrProcessor;
45+
46+
class Acme_Module_Helper_Async_Foo implements PsrProcessor
47+
{
48+
public function process(PsrMessage $message, PsrContext $context)
49+
{
50+
// do job
51+
// $message->getBody() -> 'payload'
52+
53+
return self::ACK; // acknowledge message
54+
// return self::REJECT; // reject message
55+
// return self::REQUEUE; // requeue message
56+
}
57+
}
58+
```
59+
60+
than subscribe it to a topic or several topics:
61+
62+
63+
```xml
64+
<!-- app/etc/local.xml -->
65+
66+
<config>
67+
<default>
68+
<enqueue>
69+
<processors>
70+
<foo-processor>
71+
<topic>a_topic</topic>
72+
<helper>acme/async_foo</helper>
73+
</foo-processor>
74+
</processors>
75+
</enqueue>
76+
</default>
77+
</config>
78+
```
79+
80+
and run message consume command:
81+
82+
```bash
83+
$ php shell/enqueue.php enqueue:consume -vvv --setup-broker
84+
```
85+
86+
[back to index](../index.md)

0 commit comments

Comments
 (0)