Add this line to your application's Gemfile:
gem 'message_q'
And then execute:
$ bundle
Or install it yourself as:
$ gem install message_q
This Gem presently is focused on Sneakers and RabbitMQ integration but attempts to extract a lot of code into objects that could later be more de-decoupled to Sidekiq, ZeroMQ or whatever.
ATM you must create intializers for Sneakers config,etc.
This Gem is for Consumer
worker processes that deserialize JSON into a MessageQ::BaseMessage
subclass. The latter allows for simple validation hooks.
This class is abstract and must be extended. It enforces the following required attributes:
uid
a non empty stringcreated_at
a 10 digit epoch timestamp
The tests have plenty of good examples. See spec/support/test_klasses.rb
Similar to the BaseMessage
, this must be extended and is essential (at present) a Sneakers::Worker
class with some sugar. Messages are automatically processed with a MessageQ::BaseClass
subclass (you specify) and then a handler method is called process_method
that you implement and use the message
attribute to do your work. This is the actual BaseMessage
type which has to_hash
and to_json
as well as accessors.
See source code for more info like above.
Simple class. Call class method publish!
with a MessageQ::BaseMessage
subclass, the queue
name and an options hash (optional).
It will serialize the object and place on the queue.
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/message_q.
The gem is available as open source under the terms of the MIT License.