Your focuses on ease of use. It focus on to retry send message when message broker is down
RabbitMQ 3.3+
.
Install in your Gemfile
:
gem 'hovercat', git: 'https://github.com/Mobile4You/hovercat.git'
First of all you have to genereate a configuration file
You can generate de configuration file running the following command:
$ hovercat memory_store
It will generate a configuration file like this:
hovercat:
rabbitmq:
host: 'localhost'
port: 5672
exchange: ''
vhost: '/'
user: 'guest'
password: 'guest'
retries_in_rabbit_mq:
retry_attempts: 3
retry_delay_in_seconds: 600
You can specify rabbitmq configurations in configuration file or via params in Hovercat::Sender.publish
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
To send a message, you have to use Hovercat::Sender.publish
:
Example:
message = Message.new(name: 'My name', email: '[email protected]')
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
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
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request