Skip to content

TrevorN1126/rabbitMQ-es8-tutorials

Repository files navigation

Node.js code for RabbitMQ tutorials

Here you can find JavaScript (Node) code examples from RabbitMQ tutorials using Async/ Await patterns.

All examples are wrapped in an IIAFE and use await instead of callbacks.

To successfully use the examples you will need a running RabbitMQ server.

Requirements

Node.js

You need Node.js to run these tutorials.

Client Library

amqp.node is listed as a local dependency in package.json

Run:

yarn

to install dependency.

Code

node 01-hello-world/receive.js

or

yarn 01-receive

and from a separate terminal

node 01-hello-world/send.js

or

yarn 01-send
node 02-work-queues/worker.js

or

yarn 02-worker

and from a separate terminal

node 02-work-queues/new_task.js "A very hard task which takes two seconds.."

or

yarn 02-new-task "Any string you type with dots after.."
node 03-pub-sub/receive_logs.js

or

yarn 03-receive

and from a separate terminal

node 03-pub-sub/emit_log.js "info: This is the log message"

or

yarn 03-emit "info: This is the log message"

Pipe to log file:

Windows PowerShell:

node 03-pub-sub/receive_logs.js | Out-File -FilePath 03-pub-sub/logs_from_rabbit.log

Linux:

node ./receive_logs.js > ./logs_from_rabbit.log
node 04-routing/receive_logs_direct.js info

or

yarn 04-receive info

and from a separate terminal

node 04-routing/emit_log_direct.js info "The message"

or

yarn 04-emit info "The Message"
node 05-topics/receive_logs_topic.js "*.rabbit"

or

yarn 05-receive "*.rabbit"

and from a separate terminal

node 05-topics/emit_log_topic.js red.rabbit Hello

or

yarn 05-emit red.rabbit Hello
node 06-rpc/rpc_server.js

or

yarn 06-rpc_server

and from a separate terminal

node 06-rpc/rpc_client.js 30

or

yarn 06-rpc_server 30

Releases

No releases published

Packages

No packages published