deepinpy / communications

Tool for easy and painless two-sided communication between two rails applications

Home Page:https://github.com/sck-v/communications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Communications

This gem provides tools for easy and painless two-sided communication between two rails applications

Installation

Add this line to your application's Gemfile:

gem 'communications', github: 'sck-v/communications'

And then execute:

$ bundle

Usage

The usage is simple:

Receiver App

  1. Configure receiver
Communications.configure do
  handle :channel_name, with: SomeHandler

  on_message_failure do |queue, payload, _|
    Rails.logger.info 'Message processing error'
  end
end
  1. Start the reciever
Communications::Receiver.start! rescue Bunny::TCPConnectionFailedForAllHosts
  1. Implement Handler class
require 'communications/handler'
  
class SomeHandler
  include Communications::Handler

  def handle(payload)
    SomeWorker.do_something_with_payload(payload)
  end
end

Transmitter App

  1. Publish message
Communications::Publisher.publish(:channel_name, message_hash)

About

Tool for easy and painless two-sided communication between two rails applications

https://github.com/sck-v/communications

License:MIT License


Languages

Language:Ruby 100.0%