GitHunt
GA

gamut-code/active_record_event_publisher

Publishes data change events from ActiveRecord to SQS

ActiveRecordEventPublisher

Publish all create, update, and destroy events to an SQS queue.

Installation

Add this line to your application's Gemfile:

gem 'active_record_event_publisher', :git => 'https://github.com/gamut-code/active_record_event_publisher'

Setup

Add this configuration initializer to your app

config/initializers/active_record_event_publisher.rb

ActiveRecordEventPublisher.configure do |config|
  config.queue_url = 'http://example.com'
  config.enabled = false # only enable in production environment
  config.log = true # default is false
end

Restart your app, and all events will be published to SQS.

Publish Format

The following attributes are published on each data change event:

  • action - One of the follow options, create, update, or destroy
  • subject_id - The primary key of the object affected by the change
  • subject_class - The class name of the object affected by the change
  • subject - All attributes of the object affected by the change
  • changes - Only the attributes affected by the change, including their before and after state
  • created_at - The date, time and zone of when the event happened in ISO 8601 format.
{
  "action": "(create|update|destroy)",
  "subject_id": "(objectId)",
  "subject_class": "(objectClass)",
  "subject": {
    "(objectAttribute1Key)": "(objectAttribute1Value)",
    "(objectAttribute2Key)": "(objectAttribute2Value)",
  },
  "changes": {
    "(changedAttribute1)": [
      "(changedAttribute1Before)",
      "(changedAttribute1After)"
    ],
    "(changedAttribute2)": [
      "(changedAttribute2Before)",
      "(changedAttribute2After)"
    ]
  },
  "created_at": "(timestamp)"
}

Bugs & Feature Requests

Please add an issue in Github if you discover a bug or have a feature request.

Contributing

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

License

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

Languages

Ruby85.7%HTML10.5%JavaScript2.3%CSS1.5%

Contributors

MIT License
Created March 22, 2017
Updated February 17, 2026
gamut-code/active_record_event_publisher | GitHunt