Skip to content

rajeshkumaravel/node-rabbitmq-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RabbitMQ NodeJS - Basics, Direct and Topic based


Table of contents

  • Prerequisites
  • Types
  • Running Application
  • References

Prerequisites

Tool Version
Node JS 12.13.0 (LTS)
rabbitmq_server 3.8.2

Types

  1. One to One (Direct)

    For one to one messaging, a producer sends messages to specified queue. A consumer receives messages from that queue.To ensure message is not lost, message acknowledgments can be sent back to producer to confirm a particular message has been received

    File path - "./rbmq_basic/rbmq.producer and ./rbmq_basic/rbmq.consumer"

    Ref: One to One (direct)

  2. Routing - Filter Based (Topic)

    For filter based routing, a producer declares the topic exchange when publishing a message. Messages sent with a particular routing key will be delivered to all the queues that are bound with a matching binding key. Filter based routing provides a method to use filter policies on routing key for choosing the recipients of messages.

    * (star) can substitute for exactly one word. Example: 'topic.*' can be : topic1, topic2, topic3 etc.

    # (hash) can substitute for zero or more words. Example: "#.topic" can be: topic, Ftopic, Secondtopic, 123topic etc.

    File path - "./topic"

    Ref: Routing - Filter Based (Topic)

Running Application

  1. One to One (Direct)

    Under roor directory

    cd direct

    node index.js

    node consumer.js

  2. Routing - Filter Based (Topic)

    Under roor directory

    cd topic

    node index.js

    node consumer.js

foo@bar: ~$ curl --location --request POST 'http://localhost:3343/api/v1/save' \
--header 'Content-Type: application/json' \
--data-raw '[
    {
        "postId": 1,
        "id": 1,
        "name": "id labore ex et quam laborum",
        "email": "[email protected]",
        "body": "laudantium enim quasi est quidem magnam voluptate ipsam eos\ntempora quo necessitatibus\ndolor quam autem quasi\nreiciendis et nam sapiente accusantium"
    }
]'

References

  1. Downloading and Installing RabbitMQ
  2. AMQP 0-9-1 Model Explained
  3. AMQP
  4. RabbitMQ Tutorials
  5. Enable Management Plugin
  6. amqp.node
  7. Intro — RabbitMQ Message Queue with NodeJs
  8. An Advanced Message Queuing Protocol (AMQP) Walkthrough
  9. RabbitMQ vs Kafka Part 2 - RabbitMQ Messaging Patterns

Releases

No releases published

Packages

No packages published