{"id":13877911,"url":"https://github.com/rootstrap/active_outbox","last_synced_at":"2025-10-16T03:19:26.198Z","repository":{"id":199787529,"uuid":"615124833","full_name":"rootstrap/active_outbox","owner":"rootstrap","description":"A Transactional Outbox implementation for Rails and ActiveRecord","archived":false,"fork":false,"pushed_at":"2024-10-28T18:29:15.000Z","size":134,"stargazers_count":28,"open_issues_count":3,"forks_count":2,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-06-12T01:05:04.355Z","etag":null,"topics":["activerecord","rails","transactional-outbox"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rootstrap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-17T02:08:15.000Z","updated_at":"2024-12-13T03:35:04.000Z","dependencies_parsed_at":"2023-11-16T15:42:23.397Z","dependency_job_id":"7848bba7-3ff1-4739-b195-65ffa2115d6d","html_url":"https://github.com/rootstrap/active_outbox","commit_stats":null,"previous_names":["rootstrap/active_outbox"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/rootstrap/active_outbox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rootstrap%2Factive_outbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rootstrap%2Factive_outbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rootstrap%2Factive_outbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rootstrap%2Factive_outbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rootstrap","download_url":"https://codeload.github.com/rootstrap/active_outbox/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rootstrap%2Factive_outbox/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264284357,"owners_count":23584675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activerecord","rails","transactional-outbox"],"created_at":"2024-08-06T08:01:34.685Z","updated_at":"2025-10-16T03:19:21.162Z","avatar_url":"https://github.com/rootstrap.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Active Outbox\nA Transactional Outbox implementation for Rails and ActiveRecord.\n\n![transactional outbox pattern](./docs/images/transactional_outbox.png)\n\nThis gem aims to implement the event persistance side of the pattern, focusing only on providing a seamless way to store Outbox records whenever a change occurs on a given model (#1 in the diagram).\nWe do not provide an event publisher, nor a consumer as a part of this gem since the idea is to keep it as light weight as possible.\n\n## Motivation\nIf you find yourself repeatedly defining a transaction block every time you need to persist an event, it might be a sign that something needs improvement. We believe that adopting a pattern should enhance your workflow, not hinder it. Creating, updating or destroying a record should remain a familiar and smooth process.\n\nOur primary objective is to ensure a seamless experience without imposing our own opinions or previous experiences. That's why this gem exclusively focuses on persisting records. We leave the other aspects of the pattern entirely open for your customization. You can emit these events using Sidekiq jobs, or explore more sophisticated solutions like Kafka Connect.\n\n## Why active_outbox?\n- Seamless integration with ActiveRecord\n- CRUD events out of the box\n- Ability to set custom events\n- Test helpers to easily check Outbox records are being created correctly\n- Customizable\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'active_outbox'\n```\n\nAnd then execute:\n```bash\nbundle install\n```\nOr install it yourself as:\n```bash\ngem install active_outbox\n```\n\n## Usage\n### Setup\nCreate the outbox table and model using the provided generator. Any model name can be passed as an argument but if empty it will default to `outboxes` and `Outbox` respectively.\n```bash\nrails g active_outbox:model \u003coptional model_name\u003e\n\n  create  db/migrate/20231115182800_active_outbox_create_\u003cmodel_name_\u003eoutboxes.rb\n  create  app/models/\u003cmodel_name_\u003eoutbox.rb\n```\nAfter running the migration, create an initializer under `config/initializers/active_outbox.rb` and setup the default outbox class to the new `Outbox` model you just created.\n```bash\nrails g active_outbox:install\n```\n\nTo allow models to store Outbox records on changes, you will have to include the `Outboxable` concern.\n```ruby\n# app/models/user.rb\n\nclass User \u003c ApplicationRecord\n  include ActiveOutbox::Outboxable\nend\n```\n### Base Events\nUsing the User model as an example, the default event names provided are:\n- USER_CREATED\n- USER_UPDATED\n- USER_DESTROYED\n\nThis will live under `ActiveOutbox::Events` wherever you include the `Outboxable` concern. The intent is to define it under `Object` for non-namespaced models, as well as under each model namespace that is encountered.\n\n### Custom Events\nIf you want to persist a custom event other than the provided base events, you can do so.\n```ruby\nuser.save(outbox_event: 'YOUR_CUSTOM_EVENT')\n```\n## Advanced Usage\n### Supporting UUIDs\nBy default our Outbox migration has an `aggregate_identifier` field which serves the purpose of identifying which record was involved in the event emission. We default to integer IDs, but if you're using UUIDs as a primary key for your records you have to adjust the migrations accordingly. To do so just run the model generator with the `--uuid` flag.\n```bash\nrails g active_outbox:model \u003coptional model_name\u003e --uuid\n```\n### Modularized Outbox Mappings\nIf more granularity is desired multiple outbox classes can be configured. Using the provided generators we can specify namespaces and the folder structure.\n```bash\nrails g active_outbox:model user_access/ --component-path packs/user_access\n\n  create  packs/user_access/db/migrate/20231115181205_active_outbox_create_user_access_outboxes.rb\n  create  packs/user_access/app/models/user_access/outbox.rb\n```\nAfter creating the needed `Outbox` classes for each module you can specify multiple mappings in the initializer.\n```ruby\n# frozen_string_literal: true\n\nRails.application.reloader.to_prepare do\n  ActiveOutbox.configure do |config|\n    config.outbox_mapping = {\n      'member' =\u003e 'Member::Outbox',\n      'user_access' =\u003e 'UserAccess::Outbox'\n    }\n  end\nend\n```\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/rootstrap/active_outbox. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/rootstrap/active_outbox/blob/main/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/license/mit/).\n\n## Code of Conduct\n\nEveryone interacting in the ActiveOutbox project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rootstrap/active_outbox/blob/main/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frootstrap%2Factive_outbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frootstrap%2Factive_outbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frootstrap%2Factive_outbox/lists"}