Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[magento] Add basic docs for enqueue magento extension. #76

Merged
merged 1 commit into from
May 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/bundle/cli_commands.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Cli commands

The EnqueueBundle provides several commands.
The most useful one `enqueue:consume` connects to the broker and process the messages.
Other commands could be useful during debugging (like `enqueue:topics`) or deployment (like `enqueue:setup-broker`).

* [enqueue:consume](#enqueueconsume)
* [enqueue:produce](#enqueueproduce)
* [enqueue:setup-broker](#enqueuesetup-broker)
Expand Down
Binary file added docs/images/magento_enqueue_configuration.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
- [Production settings](bundle/production_settings.md)
- [Debuging](bundle/debuging.md)
- [Functional testing](bundle/functional_testing.md)
* Magento
- [Quick tour](magento/quick_tour.md)
- [Cli commands](magento/cli_commands.md)
* Development
- [Contribution](contribution.md)

Expand Down
142 changes: 142 additions & 0 deletions docs/magento/cli_commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Cli commands

The enqueue Magento extension provides several commands.
The most useful one `enqueue:consume` connects to the broker and process the messages.
Other commands could be useful during debugging (like `enqueue:topics`) or deployment (like `enqueue:setup-broker`).

* [enqueue:consume](#enqueueconsume)
* [enqueue:produce](#enqueueproduce)
* [enqueue:setup-broker](#enqueuesetup-broker)
* [enqueue:queues](#enqueuequeues)
* [enqueue:topics](#enqueuetopics)

## enqueue:consume

```
php shell/enqueue.php enqueue:consume --help
Usage:
enqueue:consume [options] [--] [<client-queue-names>]...
enq:c

Arguments:
client-queue-names Queues to consume messages from

Options:
--message-limit=MESSAGE-LIMIT Consume n messages and exit
--time-limit=TIME-LIMIT Consume messages during this time
--memory-limit=MEMORY-LIMIT Consume messages until process reaches this memory limit in MB
--setup-broker Creates queues, topics, exchanges, binding etc on broker side.
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-e, --env=ENV The environment name [default: "dev"]
--no-debug Switches off debug mode
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
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
```

## enqueue:produce

```
php shell/enqueue.php enqueue:produce --help
Usage:
enqueue:produce <topic> <message>
enq:p

Arguments:
topic A topic to send message to
message A message to send

Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-e, --env=ENV The environment name [default: "dev"]
--no-debug Switches off debug mode
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
A command to send a message to topic
```

## enqueue:setup-broker

```
php shell/enqueue.php enqueue:setup-broker --help
Usage:
enqueue:setup-broker
enq:sb

Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-e, --env=ENV The environment name [default: "dev"]
--no-debug Switches off debug mode
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
Creates all required queues
```

## enqueue:queues

```
/bin/console enqueue:queues --help
Usage:
enqueue:queues
enq:m:q
debug:enqueue:queues

Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-e, --env=ENV The environment name [default: "dev"]
--no-debug Switches off debug mode
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
A command shows all available queues and some information about them.
```

## enqueue:topics

```
php shell/enqueue.php enqueue:topics --help
Usage:
enqueue:topics
enq:m:t
debug:enqueue:topics

Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-e, --env=ENV The environment name [default: "dev"]
--no-debug Switches off debug mode
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
A command shows all available topics and some information about them.
```

[back to index](../index.md)

86 changes: 86 additions & 0 deletions docs/magento/quick_tour.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Magento Enqueue. Quick tour

## Installation

We use [composer](https://getcomposer.org/) and [cotya/magento-composer-installer](https://github.com/Cotya/magento-composer-installer) plugin to install magento-enqueue.

To install libraries run the commands in the application root directory.

```bash
composer require "magento-hackathon/magento-composer-installer:~3.0"
composer require "enqueue/magento-enqueue:*@dev" "enqueue/amqp-ext"
```

## Configuration

At this stage we have configure the Enqueue extension in Magento backend.
The config is here: System -> Configuration -> Enqueue Message Queue.
Here's the example of Amqp transport that connects to RabbitMQ broker on localhost:


![Сonfiguration](../images/magento_enqueue_configu)

## Publish Message

To send a message you have to take enqueue helper and call `send` method.

```php
<?php

Mage::helper('enqueue')->send('a_topic', 'aMessage');
```

## Message Consumption

I assume you have `acme` Magento module properly created, configured and registered.
To consume messages you have to define a processor class first:

```php
<?php
// app/code/local/Acme/Module/Helper/Async/Foo.php

use Enqueue\Psr\PsrContext;
use Enqueue\Psr\PsrMessage;
use Enqueue\Psr\PsrProcessor;

class Acme_Module_Helper_Async_Foo implements PsrProcessor
{
public function process(PsrMessage $message, PsrContext $context)
{
// do job
// $message->getBody() -> 'payload'

return self::ACK; // acknowledge message
// return self::REJECT; // reject message
// return self::REQUEUE; // requeue message
}
}
```

than subscribe it to a topic or several topics:


```xml
<!-- app/etc/local.xml -->

<config>
<default>
<enqueue>
<processors>
<foo-processor>
<topic>a_topic</topic>
<helper>acme/async_foo</helper>
</foo-processor>
</processors>
</enqueue>
</default>
</config>
```

and run message consume command:

```bash
$ php shell/enqueue.php enqueue:consume -vvv --setup-broker
```

[back to index](../index.md)