DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Stop Writing Dialect-Specific SQL: A Unified Query Builder for Node.js
  • Lambda-Driven API Design: Building Composable Node.js Endpoints With Functional Primitives
  • Design and Implementation of Cloud-Native Microservice Architectures for Scalable Insurance Analytics Platforms
  • Design and Implementation of Cloud-Native Microservice Architectures for Scalable Insurance Analytics Platforms

Trending

  • The Cost of Knowing: When Observability Becomes the Outage
  • The 7 Pillars of Meeting Design: Transforming Expensive Conversations into Decision Assets
  • AWS Kiro: The Agentic IDE That Makes Specs the Unit of Work
  • Solving the Mystery: Why Java RSS Grows in Docker on M1 Macs
  1. DZone
  2. Data Engineering
  3. Data
  4. Understanding Microservices Choreography Using RabbitMQ and Node.js

Understanding Microservices Choreography Using RabbitMQ and Node.js

We take a brief look at the concept of microservices choreography and how this would work in an app using RabbitMQ and Node.js.

By 
Danesh Hussain Zaki user avatar
Danesh Hussain Zaki
·
Updated Feb. 20, 20 · Analysis
Likes (3)
Comment
Save
Tweet
Share
20.9K Views

Join the DZone community and get the full member experience.

Join For Free

A colleague and I had discussed the choreography of microservices a while ago and the topic came up for discussion again recently. In order to ensure that I understood the nuances correctly, I decided to write some code to implement the approach. Here are the tools/technologies that I chose:

  • Node.js for building the microservices.
  • Restify for exposing Restful APIs.
  • CloudAMQP — a RabbitMQ as a service offering as the integration bus.
  • amqp.node — a Node.js client library for RabbitMQ.

CloudAMQP offers a free tier good enough for learning and trying things out. It also comes with an easy to use management console that gives good statistics. The tutorials and articles are useful too. There is a host of options for the Node.js RabbitMQ client libraries. I tried a few and then settled with amqp.node as the RabbitMQ site had their tutorials based on it. The library comes in two flavors, one with callbacks and the other with promises. Being comfortable with callbacks, I opted for it.

Microservices architecture

Microservices architecture

The approach that I followed was to mimic a part of the order management process where a POST method triggers the order creation service. The service processes the order, creates an entry in the order management database and sends a message to a RabbitMQ topic. Another service listens to the topic for a specific key that denotes that the order creation is complete and gets triggered when a message with that key is published. This service checks for inventory and either calls a service to replenish stock if it is low or calls an order shipment service if the stock is available. It also publishes a message on the topic with the respective keys to trigger the following services.

Apache Kafka can be used as an alternative to RabbitMQ as an event bus. This approach is suitable while creating new microservices as they can be made to start on the basis of an event.

Full code is available here.

“The views expressed in this article are mine and my employer does not subscribe to the substance or veracity of my views.”

microservice Node.js

Published at DZone with permission of Danesh Hussain Zaki. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Stop Writing Dialect-Specific SQL: A Unified Query Builder for Node.js
  • Lambda-Driven API Design: Building Composable Node.js Endpoints With Functional Primitives
  • Design and Implementation of Cloud-Native Microservice Architectures for Scalable Insurance Analytics Platforms
  • Design and Implementation of Cloud-Native Microservice Architectures for Scalable Insurance Analytics Platforms

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook