This directory contains the RabbitMQ tutorials,
ported to amqplib. The sub-directory
callback_api has translations
of the tutorial programs to the callback-oriented API.
To run the tutorial code, you need amqplib installed. Assuming you are in a clone of the amqplib repository, from the tutorials directory:
or to use the latest released version,
npm install amqplib
Then just run each file as a script, e.g., in bash
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
Using RabbitMQ as a routing ('somecast') mechanism.
sends a log message with a severity, and all
processes receive log messages for the severities on which they are
Extends the previous tutorial to routing with wildcarded patterns.
Using RabbitMQ as an RPC intermediary, queueing requests for servers and routing replies back to clients.
I depart slightly from the original tutorial code, which I think has some needless object-orientation (in the Python code; you don't get a choice about needless object-orientation in Java).