Running from CLI

In order to run cli commands, you need to setup your connection, exchange and queue configuration first.

You can run cli commands like this:

$ ./vendor/bin/humus-amqp

Setting up the CLI

When you run the humus-amqp cli you may encounter this error on first run:

You are missing a "humus-amqp-config.php" or "config/humus-amqp-config.php" file in your
project, which is required to get the Humus Amqp Console working. You can use the
following sample as a template:

<?php

use Humus\Amqp\Console\ConsoleRunner;

// replace with file to your own project bootstrap
require_once 'bootstrap.php';

// replace with mechanism to retrieve the container in your app
$container = GetContainer();

return ConsoleRunner::createHelperSet($container);

To solve this, simply add a file config/humus-amqp-config.php file and use the template to setup the cli config.

Setup-Fabric

To setup all exchanges and queues configured:

$ ./vendor/bin/humus-amqp setup-fabric

This will create all exchanges and queues.

Running consumers

To start a consumer:

$ ./vendor/bin/humus-amqp consumer -n myconsumer -a 100

This will start the myconsumer and consume 100 messages until if stops or times out.

Running JSON-RPC servers

To start a JSON-RPC server

$ ./vendor/bin/humus-amqp json_rpc_server -n myserver -a 100

This will start the myserver and consume 100 messages until if stops or times out.

List amqp types

Show availables connections, exchanges, queues, callback_consumers, producers, json_rpc_clients and json_rpc_servers

$ ./vendor/bin/humus-amqp show -t exchanges

This will list all known exchanges.

Purge queues

To purge a queue:

$ ./vendor/bin/humus-amqp purge-queue -p myqueue

This will remove all messages from the given queue.

Publishing from CLI

To publish a message to an exchane via CLI:

$ ./vendor/bin/humus-amqp publish-message -p myproducer -m "my text" -c -r "my.routing.key"

This will send a message with body “my text” and routing key “my.routing.key” via the “myproducer”-producer using confirm select mode.

Troubleshooting

If you have read this guide and still have issues with connecting, check our Troubleshooting guide and feel free to raise an issue at Github.

Tell Us What You Think!

Please take a moment to tell us what you think about this guide: Send an e-mail, say hello in the HumusAmqp gitter chat. or raise an issue on Github.

Let us know what was unclear or what has not been covered. Maybe you do not like the guide style or grammar or discover spelling mistakes. Reader feedback is key to making the documentation better.