Amqphp basic demos
There are 3 scripts to demostrate the most basic usage of Amqphp:
- get.php - use the
basic.getamqp method to retrieve a single message
- producer.php - use the
basic.publishamqp method to publish one or more messages.
- consumer.php - set up a consumer to receive messages.
The first of these is very simple, the other 2 accept command line
options which vary their behaviour, use a
--help switch for more
Before you run the demos you must set up an Amqp broker, edit the connection parameters in configs/rabbit1-host-config.xml to suit your environment.
First, publish some messages:
php producer.php --message="Hello, world" --repeat=5
Now, read one of these back from the broker using get:
You should have 4 left - read these back using consume:
php consumer.php --strat="trel 1 0"
--strat switch adds an exit strategy to the connection,
without this the script will never end (until you kill it with Ctrl-C,
Here's an interesting one - set up a consumer that listens to and prints out all "system messages" from the RabbitMQ broker:
php consumer.php --consumer rmq-mon-q \ --config configs/log-and-trace-connection.xml