{"id":20127150,"url":"https://github.com/cloudamqp/amqp-client.rb","last_synced_at":"2025-04-06T20:09:28.657Z","repository":{"id":38187475,"uuid":"357620473","full_name":"cloudamqp/amqp-client.rb","owner":"cloudamqp","description":"Modern AMQP 0-9-1 Ruby client","archived":false,"fork":false,"pushed_at":"2025-03-04T14:23:57.000Z","size":716,"stargazers_count":22,"open_issues_count":2,"forks_count":7,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-30T19:05:20.099Z","etag":null,"topics":["amqp","ruby"],"latest_commit_sha":null,"homepage":"https://cloudamqp.github.io/amqp-client.rb/","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/cloudamqp.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":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-13T16:30:35.000Z","updated_at":"2025-03-04T14:24:01.000Z","dependencies_parsed_at":"2024-03-15T15:47:44.466Z","dependency_job_id":"066aa984-1726-46f9-acf6-00eaac190aac","html_url":"https://github.com/cloudamqp/amqp-client.rb","commit_stats":{"total_commits":246,"total_committers":8,"mean_commits":30.75,"dds":"0.10162601626016265","last_synced_commit":"8163bb106deb4f31beed7b5b9171850ad0861cf1"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudamqp%2Famqp-client.rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudamqp%2Famqp-client.rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudamqp%2Famqp-client.rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudamqp%2Famqp-client.rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudamqp","download_url":"https://codeload.github.com/cloudamqp/amqp-client.rb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247543589,"owners_count":20955865,"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","ruby"],"created_at":"2024-11-13T20:19:28.646Z","updated_at":"2025-04-06T20:09:28.616Z","avatar_url":"https://github.com/cloudamqp.png","language":"Ruby","readme":"# AMQP::Client\n\nA modern AMQP 0-9-1 Ruby client. Very fast (just as fast as the Java client, and \u003e4x than other Ruby clients), fully thread-safe, blocking operations and straight-forward error handling.\n\nIt's small, only ~1800 lines of code, and without any dependencies. Other Ruby clients are about 4 times bigger. But without trading functionallity.\n\nIt's safe by default, messages are published as persistent, and is waiting for confirmation from the broker. That can of course be disabled if performance is a priority.\n\n## Support\n\nThe library is fully supported by [CloudAMQP](https://www.cloudamqp.com), the largest LavinMQ and RabbitMQ hosting provider in the world. Open [an issue](https://github.com/cloudamqp/amqp-client.rb/issues) or [email our support](mailto:support@cloudamqp.com) if you have problems or questions.\n\n## Documentation\n\n[API reference](https://cloudamqp.github.io/amqp-client.rb/)\n\n## Usage\n\nThe client has two APIs.\n\n### Low level API\n\nThis API matches the AMQP protocol very well, it can do everything the protocol allows, but requires some knowledge about the protocol, and doesn't handle reconnects.\n\n```ruby\nrequire \"amqp-client\"\n\n# Opens and establishes a connection\nconn = AMQP::Client.new(\"amqp://guest:guest@localhost\").connect\n\n# Open a channel\nch = conn.channel\n\n# Create a temporary queue\nq = ch.queue_declare\n\n# Publish a message to said queue\nch.basic_publish_confirm \"Hello World!\", \"\", q.queue_name, persistent: true\n\n# Poll the queue for a message\nmsg = ch.basic_get(q.queue_name)\n\n# Print the message's body to STDOUT\nputs msg.body\n```\n\n### High level API\n\nThe library provides a high-level API that is a bit easier to get started with, and also handles reconnection automatically.\n\n```ruby\nrequire \"amqp-client\"\nrequire \"json\"\nrequire \"zlib\"\n\n# Start the client, it will connect and once connected it will reconnect if that connection is lost\n# Operation pending when the connection is lost will raise an exception (not timeout)\namqp = AMQP::Client.new(\"amqp://localhost\").start\n\n# Declares a durable queue\nmyqueue = amqp.queue(\"myqueue\")\n\n# Bind the queue to any exchange, with any binding key\nmyqueue.bind(\"amq.topic\", \"my.events.*\")\n\n# The message will be reprocessed if the client loses connection to the broker\n# between message arrival and when the message was supposed to be ack'ed.\nmyqueue.subscribe(prefetch: 20) do |msg|\n  puts JSON.parse(msg.body)\n  msg.ack\nrescue =\u003e e\n  puts e.full_message\n  msg.reject(requeue: false)\nend\n\n# Publish directly to the queue\nmyqueue.publish({ foo: \"bar\" }.to_json, content_type: \"application/json\")\n\n# Publish to any exchange\namqp.publish(\"my message\", \"amq.topic\", \"topic.foo\", headers: { foo: 'bar' })\namqp.publish(Zlib.gzip(\"an event\"), \"amq.topic\", \"my.event\", content_encoding: 'gzip')\n```\n\n## Benchmark\n\n1 byte messages:\n\n| Client | Publish rate | Consume rate | Memory usage |\n| ------ | ------------ | ------------ | ------------ |\n| amqp-client.rb | 237.000 msgs/s | 154.000 msgs/s | 23 MB |\n| bunny | 39.000 msgs/s | 44.000 msgs/s | 31 MB |\n\nGem comparison:\n\n| Client | Runtime dependencies | [Lines of code](https://github.com/AlDanial/cloc) |\n| --- | --- | --- |\n| amqp-client.rb | 0 | 1876 |\n| bunny | 2 | 4003 |\n\n## Supported Ruby versions\n\nAll maintained Ruby versions are supported.\n\nSee the [CI workflow](https://github.com/cloudamqp/amqp-client.rb/blob/main/.github/workflows/main.yml) for the exact versions.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'amqp-client'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install amqp-client\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the changelog and version number in `version.rb`, make a commit, and then run `bundle exec rake release:source_control_push`, which will create a git tag for the version, push git commits and the created tag. GitHub Actions will then push the `.gem` file to [rubygems.org](https://rubygems.org/gems/amqp-client).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at [https://github.com/cloudamqp/amqp-client.rb](https://github.com/cloudamqp/amqp-client.rb/)\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudamqp%2Famqp-client.rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudamqp%2Famqp-client.rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudamqp%2Famqp-client.rb/lists"}