{"id":19134034,"url":"https://github.com/umbrellio/rabbit_messaging","last_synced_at":"2025-04-15T21:23:33.764Z","repository":{"id":45297370,"uuid":"190468247","full_name":"umbrellio/rabbit_messaging","owner":"umbrellio","description":"Rabbit (Rabbit Messaging) - Provides client and server support for RabbitMQ","archived":false,"fork":false,"pushed_at":"2025-04-14T13:30:20.000Z","size":91,"stargazers_count":4,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-14T13:43:32.280Z","etag":null,"topics":["rabbitmq","rabbitmq-client","rabbitmq-ruby","rabbitmq-server"],"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/umbrellio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2019-06-05T21:03:14.000Z","updated_at":"2025-04-14T13:30:24.000Z","dependencies_parsed_at":"2024-11-16T15:04:00.045Z","dependency_job_id":"8745a876-067b-45d0-bcba-ae894535c0bf","html_url":"https://github.com/umbrellio/rabbit_messaging","commit_stats":{"total_commits":36,"total_committers":12,"mean_commits":3.0,"dds":0.5833333333333333,"last_synced_commit":"b684ca921eb134c02986342a3dd62791c4c58bf0"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umbrellio%2Frabbit_messaging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umbrellio%2Frabbit_messaging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umbrellio%2Frabbit_messaging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umbrellio%2Frabbit_messaging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/umbrellio","download_url":"https://codeload.github.com/umbrellio/rabbit_messaging/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249155158,"owners_count":21221550,"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":["rabbitmq","rabbitmq-client","rabbitmq-ruby","rabbitmq-server"],"created_at":"2024-11-09T06:25:00.940Z","updated_at":"2025-04-15T21:23:33.740Z","avatar_url":"https://github.com/umbrellio.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rabbit (Rabbit Messaging) \u0026middot;  [![Gem Version](https://badge.fury.io/rb/rabbit_messaging.svg)](https://badge.fury.io/rb/rabbit_messaging) [![Coverage Status](https://coveralls.io/repos/github/umbrellio/rabbit_messaging/badge.svg?branch=master)](https://coveralls.io/github/umbrellio/rabbit_messaging?branch=master)\n\nProvides client and server support for RabbitMQ\n\n## Installation\n\n```ruby\ngem \"rabbit_messaging\"\n```\n\n```shell\n$ bundle install\n# --- or ---\n$ gem install \"rabbit_messaging\"\n```\n\n```ruby\nrequire \"rabbit_messaging\"\n```\n\n## Usage\n\n- [Configuration](#configuration)\n- [Client](#client)\n- [Server](#server)\n\n---\n\n### Configuration\n\n- RabbitMQ connection configuration fetched from the `bunny_options` section\n  of `/config/sneakers.yml`\n\n- `Rabbit.config` provides setters for following options:\n\n  - `group_id` (`Symbol`), *required*\n\n    Shared identifier which used to select api. As usual, it should be same as default project_id\n    (I.e. we have project 'support', which runs only one application in production.\n    So on, it's group_id should be :support)\n\n  - `project_id` (`Symbol`), *required*\n\n    Personal identifier which used to select exact service.\n    As usual, it should be same as default project_id with optional stage_id.\n    (I.e. we have project 'support', in production it's project_id is :support,\n    but in staging it uses :support1 and :support2 ids for corresponding stages)\n\n  - `queue_suffix` (`String`)\n\n    Optional suffix added to the read queue name. For example, in case of `group_id = \"grp\"`, `project_id = \"prj\"` and\n    `queue_suffix = \"sfx\"`, Rabbit will read from queue named `\"grp.prj.sfx\"`.\n\n  - `exception_notifier` (`Proc`)\n    You must provide your own notifier like this to notify about exceptions:\n\n    ```ruby\n      config.exception_notifier = proc { |e| MyCoolNotifier.notify!(e) }\n    ```\n\n  - `hooks` (`Hash`)\n\n    :before_fork and :after_fork hooks, used same way as in unicorn / puma / que / etc\n\n  - `environment` (one of `:test`, `:development`, `:production`), *default:- `:production`\n\n    Internal environment of gem.\n\n    - `:test` environment stubs publishing and does not suppress errors\n    - `:development` environment auto-creates queues and uses default exchange\n    - `:production` environment enables handlers caching and gets maximum strictness\n\n    By default gem skips publishing in test and development environments.\n    If you want to change that then manually set `Rabbit.skip_publishing_in` with an array of environments.\n\n    ```ruby\n     Rabbit.skip_publishing_in = %i[test]\n    ```\n\n  - `receiving_job_class_callable` (`Proc`)\n\n    Custom ActiveJob subclass to work with received messages. Receives the following attributes as `kwarg`-arguments:\n\n    - `:arguments` - information about message type (`type`), application id (`app_id`), message id (`message_id`);\n    - `:delivery_info` - information about `exchange`, `routing_key`, etc;\n    - `:message` - received RabbitMQ message (often in a `string` format);\n\n    ```ruby\n    {\n      message: '{\"hello\":\"world\",\"foo\":\"bar\"}',\n      delivery_info: { exchange: \"some exchange\", routing_key: \"some_key\" },\n      arguments: {\n        type: \"some_successful_event\",\n        app_id: \"some_group.some_app\",\n        message_id: \"uuid\",\n      }\n    }\n    ```\n\n  - `before_receiving_hooks, after_receiving_hooks` (`Array of Procs`)\n\n    Before and after hooks with message processing in the middle. Where `before_receiving_hooks` and `after_receiving_hooks` are empty arrays by default.\n\n    It's advised to NOT place procs with long execution time inside.\n\n    Setup:\n\n    ```ruby\n      config.before_receiving_hooks.append(proc { |message, arguments| do_stuff_1 })\n      config.before_receiving_hooks.append(proc { |message, arguments| do_stuff_2 })\n\n      config.after_receiving_hooks.append(proc { |message, arguments| do_stuff_3 })\n      config.after_receiving_hooks.append(proc { |message, arguments| do_stuff_4 })\n    ```\n\n  - `use_backoff_handler` (`Boolean`)\n\n    If set to `true`, use `ExponentialBackoffHandler`. You will also need add the following line to your Gemfile:\n\n    ```ruby\n    gem \"sneakers_handlers\", github: \"umbrellio/sneakers_handlers\"\n    ```\n\n    See https://github.com/umbrellio/sneakers_handlers for more details.\n\n\n  - `backoff_handler_max_retries` (`Integer`)\n\n    Number of retries that `ExponentialBackoffHandler` will use before sending job to the error queue. 5 by default.\n\n  - `connection_reset_exceptions` (`Array`)\n\n    Exceptions for reset connection. Default:  [`Bunny::ConnectionClosedError`].\n\n  ```ruby\n    config.connection_reset_exceptions \u003c\u003c MyInterestingException\n  ```\n\n  - `connection_reset_max_retries` (`Integer`)\n\n    Maximum number of reconnection attempts after a connection loss. Default: 10.\n  \n    ```ruby\n      config.connection_reset_max_retries = 20\n    ```\n\n  - `connection_reset_timeout` (`Float`)\n\n    The timeout duration before attempting to reset the connection. Default: 0.2 sec.\n\n    ```ruby\n      config.connection_reset_timeout = 0.2\n    ```\n---\n\n### Client\n\n```ruby\nRabbit.publish(\n  routing_key: :support,\n  event: :ping,\n  data: { foo: :bar }, # default is {}\n  exchange_name: 'fanout', # default is fine too\n  confirm_select: true, # setting this to false grants you great speed up and absolutelly no guarantees\n  headers: { \"foo\" =\u003e \"bar\" }, # custom arguments for routing, default is {}\n  message_id: \"asdadsadsad\", # A unique identifier such as a UUID that your application can use to identify the message.\n)\n```\n\n- This code sends messages via basic_publish with following parameters:\n\n  - `routing_key`: `\"support\"`\n  - `exchange`: `\"group_id.project_id.fanout\"` (default is `\"group_id.poject_id\"`)\n  - `mandatory`: `true` (same as confirm_select)\n\n    It is set to raise error if routing failed\n\n  - `persistent`: `true`\n  - `type`: `\"ping\"`\n  - `content_type`: `\"application/json\"` (always)\n  - `app_id`: `\"group_id.project_id\"`\n\n- Messages are logged to `/log/rabbit.log`\n\n---\n\n### Server\n\n- Server is supposed to run inside a daemon via the `daemons-rails` gem. Server is run with\n`Rabbit::Daemon.run`. `before_fork` and `after_fork` procs in `Rabbit.config` are used\nto teardown and setup external connections between daemon restarts, for example ORM connections\n\n- After the server runs, received messages are handled by `Rabbit::EventHandler` subclasses in two possible ways:\n  - a)  Subclasses are selected by following code(by default):\n    ```ruby\n    rabbit/handler/#{group_id}/#{event}\".camelize.constantize\n    ```\n  - b) you can change default behaviour to your own logic by setting the `handler_resolver_callable` config option with a `Proc` that should return the handler class:\n    ```ruby\n    Rabbit.config.handler_resolver_callable = -\u003e (group_id, event) { \"recivers/#{group_id}/#{event}\".camelize.constantize }\n    ```\n\n  They use powerful `Tainbox` api to handle message data. Project_id also passed to them.\n\n  If you wish so, you can override `initialize(message)`, where message is an object\n  with simple api (@see lib/rabbit/receiving/message.rb)\n\n  Handlers can specify a queue their messages will be put in via a `queue_as` class macro (accepts\n  a string / symbol / block with `|message, arguments|` params)\n\n- Received messages are logged to `/log/sneakers.log`, malformed messages are logged to\n`/log/malformed_messages.log` and deleted from queue\n\n---\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/umbrellio/rabbit_messaging.\n\n## License\n\nReleased under MIT License\n\n## Authors\n\nTeam Umbrellio\n\n---\n\n\u003ca href=\"https://github.com/umbrellio/\"\u003e\n\u003cimg style=\"float: left;\" src=\"https://umbrellio.github.io/Umbrellio/supported_by_umbrellio.svg\"\nalt=\"Supported by Umbrellio\" width=\"439\" height=\"72\"\u003e\n\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumbrellio%2Frabbit_messaging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fumbrellio%2Frabbit_messaging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumbrellio%2Frabbit_messaging/lists"}