README.md
RabbitMQ tutorials
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.
Preparation
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 ../..
or to use the latest released version,
npm install amqplib
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
Tutorial one: Hello World!
A "Hello World" example, with one script sending a message to a queue, and another receiving messages from the same queue.
Tutorial two: Work queues
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.
Tutorial three: Publish/Subscribe
Using RabbitMQ as a broadcast mechanism. emit_log sends a "log"
message to a fanout exchange, and all receive_logs processes receive
log messages.
Tutorial four: Routing
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.
Tutorial five: Topics
Extends the previous tutorial to routing with wildcarded patterns.
Tutorial six: RPC
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).