alexismansilla / liam

Improved communication between our (Ruby on Rails) apps with AWS SNS - SQS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Welcome to Liam Gem!

Liam is an integration between your (Ruby on Rails) App and SNS, SQS AWS Services. It allows sending a message to the AWS queue (SQS) and then processing the topic name on other (Ruby on Rails) App. (microservices)

We called it Liam in honor to (Liam Neeson) for so many reasons!

Image

Liam sends an important message to Marko from Tropoja

I DONT KNOW WHO YOU ARE, I DON’T KNOW WHAT YOU WANT, BUT I WILL FIND YOU AND I WILL KILL YOU...

We have a medium post Here on how we improved communication between our (Ruby on Rails) apps and avoided creating new endpoints in our apps. But what happens when the App A needs data from App B and App B is down for a microsecond?

Welcome, Liam!

With Liam we can send a message easily to SQS Service through SNS Service and process the message data through the consumer that Liam has

The first thing:

  • What's SNS Service? Amazon Simple Notification Service (SNS) Documentation

  • What's SQS Service? Amazon Simple Queue Service (SQS) Documentation

Image

Installation

Add this line to your application's Gemfile:

  gem 'liam', git: 'https://github.com/alexismansilla/liam.git'

  $ bundle install

If you want the liam file in your rails app then execute:

  $ bundle exec rails install:liam

We're going to create 2 Liam files

  1. /config/liam.yaml
  2. /lib/task/liam.rake

Usage

  • Producer Message
  message    = { id: self.id, title: self.title, created_at: self.created_at }.to_json
  topic_name = 'liam_CreateArticle'

  Liam::Producer.message(topic: topic_name, message: message)
  • Consumer Message
  Liam::Consumer.message

Testing

Can you run the test easily executing

  bundle exec rspec

if you want to run all test successfully, we need the LocalStack daemon when sending a message

Localstack Running

TODO

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/alexismansilla/liam.

About

Improved communication between our (Ruby on Rails) apps with AWS SNS - SQS

License:MIT License


Languages

Language:Ruby 99.4%Language:Shell 0.6%