Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
email-microservice
invoice-microservice
order-microservice
sms-microservice
.gitignore
README.md

README.md

Post Orders Microservices

A sample setup to show how to handle and setup a microservices architecture using Ruby and RabbitMQ without any frameworks.

Gems used are

How it works

  • order-microservice exposes an API /orders for order creation
  • Once an order is created and stored in the db, its pushed to orders RabbitMQ queue
  • invoice-microservice consumes from the orders queue, generates an invoice, stores in db and pushes the order+invoice payload to two queues - invoices_sms and invoices_email
  • email-microservice and sms-microservice consume from their respective queues and send email/sms

Set up locally

  • Install rabbitmq, ruby, postgresql and clone the repo. Make sure rabbitmq service is running
  • Create postgresql databases orders and invoices
createdb orders
createdb invoices
  • Install the gems in each service
cd order-microservice
bundle install
cd ../invoice-microservice
bundle install
cd ../email-microservice
bundle install
cd ../sms-microservice
bundle install
  • Start the server in the order-microservice and consumers in the other services, each in their own bash sessions
cd order-microservice
rackup --port 3000

cd invoice-microservice
rake consumer_orders

cd email-microservice
rake consume_invoices

cd sms-microservice
rake consume_invoices

  • Make a POST call to the orders-service to create an order and see it pass through the queues till both an sms and email can be generated
curl -X POST -d '{"product_name": "jeans","quantity":"17","email":"example@gmail.com","phone":"9999999999","address": "asdasda"}' http://localhost:3000/order -H "Content-Type: application/json"

You can’t perform that action at this time.