diff --git a/docs/bundle/cli_commands.md b/docs/bundle/cli_commands.md index eded37430..0e89f1256 100644 --- a/docs/bundle/cli_commands.md +++ b/docs/bundle/cli_commands.md @@ -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) diff --git a/docs/images/magento_enqueue_configuration.jpeg b/docs/images/magento_enqueue_configuration.jpeg new file mode 100644 index 000000000..73b39731e Binary files /dev/null and b/docs/images/magento_enqueue_configuration.jpeg differ diff --git a/docs/index.md b/docs/index.md index d8c9258cc..3ec90b99f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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) diff --git a/docs/magento/cli_commands.md b/docs/magento/cli_commands.md new file mode 100644 index 000000000..e6681b90a --- /dev/null +++ b/docs/magento/cli_commands.md @@ -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] [--] []... + 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 + 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) + diff --git a/docs/magento/quick_tour.md b/docs/magento/quick_tour.md new file mode 100644 index 000000000..aa4c361d9 --- /dev/null +++ b/docs/magento/quick_tour.md @@ -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 +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 +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 + + + + + + + + a_topic + acme/async_foo + + + + + +``` + +and run message consume command: + +```bash +$ php shell/enqueue.php enqueue:consume -vvv --setup-broker +``` + +[back to index](../index.md) \ No newline at end of file