It will retry sending messages when the message broker is down.
RabbitMQ 3.3+
.
Install in your Gemfile
:
gem 'hovercat', git: 'https://github.com/Mobile4You/hovercat.git'
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.
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).
- 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