This directory contains the RabbitMQ tutorials, ported to amqplib.
To run the tutorial code, you need amqplib installed. Assuming you are in a clone of the amqplib repository, from the tutorials directory:
npm install ../..
Then just run each file as a script, e.g., in bash
./send.js
or
node send.js
or
nave use 0.8 node send.js
A "Hello World" example, with one script sending a message to a queue, and another receiving messages from the same queue.
Using RabbitMQ as a work queue; new_task
creates a task, and
worker
processes tasks. Multiple worker
process will share the
tasks among them. Long-running tasks are simulated by supplying a
string with dots, e.g., '...' to new_task
. Each dot makes the worker
"work" for a second.
Using RabbitMQ as a broadcast mechanism. emit_log
sends a "log"
message to a fanout exchange, and all receive_logs
processes receive
log messages.
Using RabbitMQ as a routing ('somecast') mechanism. emit_log_direct
sends a log message with a severity, and all receive_logs_direct
processes receive log messages for the severities on which they are
listening.
Extends the previous tutorial to routing with wildcarded patterns.