JsonapiPublisher

Use this gem to publish events as JSON API to RabbitMQ. It requires ActiveModelSerializers with JSONAPI enabled as the adapter.

Usage

routing_key = "this.is.your.standard.rabbitmq.routing.key"
object = YourActiveRecordModel.create(...)
JsonapiPublisher.publish(routing_key, object, "CREATED")

Installation

Choose sqs or rabbit mq with
gem 'bunny', '~> 2.7'
or
gem 'aws-sdk', '~> 2'

Add this line to your application's Gemfile:

gem 'jsonapi_publisher'

And then execute:

$ bundle

Or install it yourself as:

$ gem install jsonapi_publisher

Configuration

Inside config\initializers\jsonapi_publisher.rb put

JsonapiPublisher.configure do |config|
  config.qservice = XXX # XXX can be 'sqs' or 'rmq'
end

Testing

Run docker run -p 9324:9324 lightspeedretail/fake-sqs docker run -d -p 5672:5672 rabbitmq:latest rake test

License

The gem is available as open source under the terms of the MIT License.