Skip to content

RabbitMQ connection abstraction with a retry handle

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
MIT-LICENSE
Notifications You must be signed in to change notification settings

Mobile4You/hovercat

Repository files navigation

Code Climate codebeat badge Build Status

Hovercat

Hovercat is a client for Rabbitmq

It will retry sending messages when the message broker is down.

Supported RabbitMQ Versions

RabbitMQ 3.3+.

Installation & Bundler Dependency

Install in your Gemfile:

gem 'hovercat', git: 'https://github.com/Mobile4You/hovercat.git'

Getting Started

1 - First of all you have to generate a configuration file, with this command:

$ hovercat memory_store

You could also use redis store:

$ hovercat redis_store

The configuration file will be generated inside the ./config dir.

You can also send the rabbitmq configurations via params to Hovercat::Sender.publish

2 - Creating hovercat message is very simple, you only have to extend Hovercat::Models::Message:

Example:

  class Message < Hovercat::Models::Message
    def initialize(name:, email:)
      super('my.routing.key.name')
    
      add resource: name, as: :name
      add resource: email, as: :email
    end
  end

3 - To send a message, you have to use Hovercat::Sender.publish:

Example:

  message = Message.new(name: 'My name', email: 'myemail@example.com')
  params = { message: message, exchange: 'my-exchange', header: { 'header-example': 'my-header'} }
  Hovercat::Sender.publish(params)

If you use exchange via param, it has precedence over exchange name in configuration file.

If you have an old version of hovercat and would like to upgrade:

1 - Execute

bundle update hovercat

2 - Change your message model

from:

Hovercat::Message
Hovercat::MessageGateway
Hovercat::UnableToSendMessageError

to:

Hovercat::Models::Message
Hovercat::Gateways::MessageGateway
Hovercat::Errors::UnableToSendMessageError

3 - You may also need to re-generate the configuration file, since the configuration is now defined per environment (development, test, production, etc).

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request