{"id":16956968,"url":"https://github.com/jgraichen/msgr","last_synced_at":"2025-04-06T08:15:44.974Z","repository":{"id":10082416,"uuid":"12139754","full_name":"jgraichen/msgr","owner":"jgraichen","description":"A Rails-like Messaging Framework using AMQP/RabbitMQ","archived":false,"fork":false,"pushed_at":"2025-01-17T17:30:07.000Z","size":319,"stargazers_count":22,"open_issues_count":2,"forks_count":5,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-30T07:11:21.023Z","etag":null,"topics":["amqp","rails","ruby","ruby-on-rails"],"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/jgraichen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-08-15T17:42:05.000Z","updated_at":"2025-01-17T17:30:08.000Z","dependencies_parsed_at":"2024-10-26T21:19:45.480Z","dependency_job_id":"7d55ae5e-4533-4a54-a404-6c7fc60a3bee","html_url":"https://github.com/jgraichen/msgr","commit_stats":{"total_commits":324,"total_committers":10,"mean_commits":32.4,"dds":0.5,"last_synced_commit":"e153e553bd654861f02488f894bdcabbf4b946b0"},"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgraichen%2Fmsgr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgraichen%2Fmsgr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgraichen%2Fmsgr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgraichen%2Fmsgr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jgraichen","download_url":"https://codeload.github.com/jgraichen/msgr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247451666,"owners_count":20940944,"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":["amqp","rails","ruby","ruby-on-rails"],"created_at":"2024-10-13T22:16:29.245Z","updated_at":"2025-04-06T08:15:44.951Z","avatar_url":"https://github.com/jgraichen.png","language":"Ruby","readme":"# Msgr: _Rails-like Messaging Framework_\n\n[![Gem](https://img.shields.io/gem/v/msgr?logo=rubygems)](https://rubygems.org/gems/msgr)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/jgraichen/msgr/test.yml?branch=main\u0026logo=github)](https://github.com/jgraichen/msgr/actions/workflows/test.yml)\n[![RubyDoc Documentation](http://img.shields.io/badge/rubydoc-here-blue.svg)](http://rubydoc.info/github/jgraichen/msgr/master/frames)\n\nYou know it and you like it. Using Rails you can just declare your routes and\ncreate a controller. That's all you need to process requests.\n\nWith _Msgr_ you can do the same for asynchronous AMQP messaging. Just define\nyour routes, create your consumer and watch your app processing messages.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'msgr', '~\u003e 1.5'\n```\n\nAnd then execute:\n\n```console\nbundle\n```\n\nOr install it yourself as:\n\n```console\ngem install msgr\n```\n\n## Usage\n\nAfter adding 'msgr' to your Gemfile create a `config/rabbitmq.yml` like this:\n\n```yaml\ncommon: \u0026common\n  uri: amqp://localhost/\n\ntest:\n  \u003c\u003c: *common\n\ndevelopment:\n  \u003c\u003c: *common\n\nproduction:\n  \u003c\u003c: *common\n```\n\nSpecify your messaging routes in `config/msgr.rb`:\n\n```ruby\nroute 'local.test.index', to: 'test#index'\nroute 'local.test.another_action', to: 'test#another_action'\n```\n\nCreate your consumer in `app/consumers`:\n\n```ruby\nclass TestConsumer \u003c Msgr::Consumer\n  def index\n    data = { fuubar: 'abc' }\n\n    publish data, to: 'local.test.another_action'\n  end\n\n  def another_action\n    puts \"#{payload.inspect}\"\n  end\nend\n```\n\nUse `Msgr.publish` in to publish a message:\n\n```ruby\nclass TestController \u003c ApplicationController\n  def index\n    @data = { abc: 'abc' }\n\n    Msgr.publish @data, to: 'local.test.index'\n\n    render nothing: true\n  end\nend\n```\n\nRun client daemon with `bundle exec msgr`.\n\n## Advanced configuration\n\n### Manual message acknowledgments\n\nPer default messages are automatically acknowledged, if no (n)ack is sent explicitly by the consumer. This can be disabled by setting the `auto_ack` attribute to `false`.\n\n```ruby\nclass TestConsumer \u003c Msgr::Consumer\n  self.auto_ack = false\n\n  def index\n    data = { fuubar: 'abc' }\n\n    publish data, to: 'local.test.another_action'\n  end\nend\n```\n\n### Prefetch count\n\nPer default each message queue has a prefetch count of 1. This value can be changed when specifying the messaging routes:\n\n```ruby\nroute 'local.test.index', to: 'test#index', prefetch: 42\n```\n\n## Testing\n\n### Recommended configuration\n\n```yaml\ntest:\n  \u003c\u003c: *common\n  pool_class: Msgr::TestPool\n  raise_exceptions: true\n```\n\nThe `Msgr::TestPool` pool implementation executes all consumers synchronously.\nBy enabling the `raise_exceptions` configuration flag, we can ensure that exceptions raised in a consumer will not be swallowed by dispatcher (which it usually does in order to retry consuming the message).\n\n### RSpec example\n\nIn your `spec_helper.rb`:\n\n```ruby\nconfig.after(:each) do\n  # Flush the consumer queue\n  Msgr.client.stop delete: true\n  Msgr::TestPool.reset\nend\n```\n\nIn a test:\n\n```ruby\nbefore { Msgr.client.start }\n\nit 'executes the consumer' do\n  # Publish an event on our queue\n  Msgr.publish 'payload', to: 'msgr.queue.my_queue'\n\n  # Let the TestPool handle exactly one event\n  Msgr::TestPool.run count: 1\n\n  # And finally, assert that something happened\n  expect(actual).to eq expected\nend\n```\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgraichen%2Fmsgr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjgraichen%2Fmsgr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgraichen%2Fmsgr/lists"}