Giter Club home page Giter Club logo

asynchronous-service's Introduction

Making Services Asynchronous using RabbitMQ:

Tasks which can be done in asynchronous mode and doesn't require client to wait until its done are asynchronous tasks. This we can achieve using Message Queues and a service provider for the same is RabbitMQ.
Apart from providing aynchronous functionality, if we have various workers running then RabbitMQ also does Load Balancing by using Round-Robin Technique.

While learning High Level Design from Gaurav Sen's Youtube channel. He mentioned how useful and powerful Message Queue is,
I wanted to see the result of how this actually performs.

Thought of implementing an email-service using nodemailer. Made a small module (customer registration and ordering items) just for invoking email service to check if its working in asynchronous mode or not and how well it is performing.

After customer calls API for placing an order. They should not wait until the email is sent and the whole process is completed. This should be done in asynchronous mode. Meanwhile customer will be able to call other APIs of views products/items without waiting for response.

For demo purpose I have taken a timer for 1 minute at the email-service:

In synchronized mode: if message queue is not used user will have to wait until this process is completed which is of 1 minute and then they will be able to do other tasks. (BLOCKED TIME)
In this project we kept email-service as asynchronized mode: user's request will be stored in message queue and they will be able to do other tasks which will enhance user experience. (NO BLOCKING TIME)

DOCKER:
To run this project one needs to clone this repository and do:

create your own .env file in the directories backend-service and email-service.


In backend-service: Mention ATLAS_URL variable and assign its value to the link of MongoDB URL which enables you to connect.
Also mention PORT variable and assign its value to the port you want your backend server to run. Take 5000 as PORT or change it in docker-compose.yml also accordingly.


In email-service: Mention USER and PASS variables and assign them values of your email account from which email will be sent.


Then, run COMMAND:
docker-compose up

Project

asynchronous-service's People

Contributors

tusharsnagpal avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.