Skip to content

Latest commit

 

History

History
88 lines (58 loc) · 2.67 KB

README.md

File metadata and controls

88 lines (58 loc) · 2.67 KB

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

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.

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