Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Fetching latest commit…

Cannot retrieve the latest commit at this time

..
Failed to load latest commit information.
README.md
emit_log.js
emit_log_direct.js
emit_log_topic.js
new_task.js
package.json
receive.js
receive_logs.js
receive_logs_direct.js
receive_logs_topic.js
rpc_client.js
rpc_server.js
send.js
worker.js

README.md

RabbitMQ tutorials

This directory contains the RabbitMQ tutorials, ported to amqplib.

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).

Something went wrong with that request. Please try again.