{"id":28546384,"url":"https://github.com/ulule/amqpx","last_synced_at":"2025-08-02T03:33:53.052Z","repository":{"id":57481635,"uuid":"72114724","full_name":"ulule/amqpx","owner":"ulule","description":"An extension for Go AMQP library","archived":false,"fork":false,"pushed_at":"2018-10-04T16:17:30.000Z","size":147,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":8,"default_branch":"dev","last_synced_at":"2025-07-07T06:42:54.300Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/ulule.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-27T14:11:07.000Z","updated_at":"2018-11-05T17:10:29.000Z","dependencies_parsed_at":"2022-09-26T17:41:10.307Z","dependency_job_id":null,"html_url":"https://github.com/ulule/amqpx","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ulule/amqpx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ulule%2Famqpx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ulule%2Famqpx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ulule%2Famqpx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ulule%2Famqpx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ulule","download_url":"https://codeload.github.com/ulule/amqpx/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ulule%2Famqpx/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268331001,"owners_count":24233158,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-06-09T23:39:16.646Z","updated_at":"2025-08-02T03:33:53.039Z","avatar_url":"https://github.com/ulule.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AMQPX\n\n[![CircleCI][circle-img]][circle-url]\n[![Documentation][godoc-img]][godoc-url]\n![License][license-img]\n\n*An extension for Go AMQP library.*\n\n## Introduction\n\n`amqpx` is an extension around [github.com/streadway/amqp](https://github.com/streadway/amqp) to provides high level functionality such as:\n\n * Client with connection recovery.\n * Client with connection pool.\n * Dialer with cluster support.\n\n## Installation\n\nUsing [dep](https://github.com/golang/dep)\n\n```console\ndep ensure -add github.com/ulule/amqpx@v2.1.0\n```\n\nor `go get`\n\n```console\ngo get -u github.com/ulule/amqpx\n```\n\n## Usage\n\n`amqpx` helps you retrieve channels from a `Client`:\n\n```go\n// Client interface describes a amqp client.\ntype Client interface {\n\t// Channel returns a new Channel from current client unless it's closed.\n\tChannel() (*amqp.Channel, error)\n\n\t// Close closes the client.\n\tClose() error\n\n\t// IsClosed returns if the client is closed.\n\tIsClosed() bool\n}\n```\n\nOnce a channel is acquired, use it as a simple AMQP channel: **there is no abstractions**.\n\nHowever, if your channel is closed because there are network connectivity issues on your server _(for example)_,\njust recycle your channel by querying a new one from your `Client` instance.\nDepending on your configuration, the client will try to create a new channel from a healthy connection.\n\n### Example\n\n#### Simple\n\nThe `SimpleDialer` only handles an unique broker uri.\n\n```go\npackage main\n\nimport (\n\t\"github.com/streadway/amqp\"\n\t\"github.com/ulule/amqpx\"\n)\n\nfunc main() {\n\turi := \"amqp://guest:guest@127.0.0.1:5672/amqpx\"\n\n\tdialer, err := amqpx.SimpleDialer(uri)\n\tif err != nil {\n\t\t// Handle error...\n\t}\n\n\tclient, err := amqpx.New(dialer, amqpx.WithCapacity(20))\n\tif err != nil {\n\t\t// Handle error...\n\t}\n\n\tchannel, err := client.Channel()\n\tif err != nil {\n\t\t// Handle error...\n\t}\n\n\t// Publish and/or receive messages using your channel.\n\n}\n```\n\nSee [examples](examples/simple) directory for further information.\n\n#### Cluster\n\nThe cluster mode can be enabled by using `ClusterDialer`.\n\nYou will be able to set multiple broker uri and still create channels using the connection pool.\n\n```go\npackage main\n\nimport (\n\t\"time\"\n\n\t\"github.com/streadway/amqp\"\n\t\"github.com/ulule/amqpx\"\n)\n\nfunc main() {\n\turis := []string{\n\t\t\"amqp://guest:guest@127.0.0.1:5672/amqpx\",\n\t\t\"amqp://guest:guest@127.0.0.1:5673/amqpx\",\n\t\t\"amqp://guest:guest@127.0.0.1:5674/amqpx\",\n\t}\n\n\tdialer, err := amqpx.ClusterDialer(uris,\n\t\tamqpx.WithDialerTimeout(1 * time.Second),\n\t\tamqpx.WithDialerTimeout(200 * time.Millisecond),\n\t)\n\tif err != nil {\n\t\t// Handle error...\n\t}\n\n\tclient, err := amqpx.New(dialer, amqpx.WithCapacity(60))\n\tif err != nil {\n\t\t// Handle error...\n\t}\n\n\tchannel, err := client.Channel()\n\tif err != nil {\n\t\t// Handle error...\n\t}\n\n\t// Publish and/or receive messages using your channel.\n\n}\n```\n\n#### With Observer and Logger\n\nAn `Observer` allows you to detect when an error occured or when a connection is closed.\n\n`amqpx` provides a default implementation of an `Observer`, same thing for the `Logger`.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/rs/zerolog/log\"\n\t\"github.com/streadway/amqp\"\n\t\"github.com/ulule/amqpx\"\n)\n\ntype ZeroLogger struct{}\n\nfunc (ZeroLogger) Debug(args ...interface{}) {\n\tlog.Debug().Msg(fmt.Sprint(args...))\n}\n\nfunc (ZeroLogger) Info(args ...interface{}) {\n\tlog.Info().Msg(fmt.Sprint(args...))\n}\n\nfunc (ZeroLogger) Warn(args ...interface{}) {\n\tlog.Warn().Msg(fmt.Sprint(args...))\n}\n\nfunc (ZeroLogger) Error(args ...interface{}) {\n\tlog.Error().Msg(fmt.Sprint(args...))\n}\n\ntype ZeroObserver struct{}\n\nfunc (ZeroObserver) OnError(err error) {\n\tlog.Error().Err(err).Msg(\"An error has occurred\")\n}\n\nfunc (ZeroObserver) OnClose(err error) {\n\tlog.Warn().Err(err).Msg(\"A close/shutdown error occured\")\n}\n\nfunc main() {\n\turis := []string{\n\t\t\"amqp://guest:guest@127.0.0.1:5672/amqpx\",\n\t\t\"amqp://guest:guest@127.0.0.1:5673/amqpx\",\n\t\t\"amqp://guest:guest@127.0.0.1:5674/amqpx\",\n\t}\n\n\tdialer, err := amqpx.ClusterDialer(uris,\n\t\tamqpx.WithDialerTimeout(1 * time.Second),\n\t\tamqpx.WithDialerTimeout(200 * time.Millisecond),\n\t)\n\tif err != nil {\n\t\t// Handle error...\n\t}\n\n\tclient, err := amqpx.New(dialer,\n\t\tamqpx.WithCapacity(60),\n\t\tamqpx.WithLogger(ZeroLogger{}),\n\t\tamqpx.WithObserver(ZeroObserver{}),\n\t)\n\tif err != nil {\n\t\t// Handle error...\n\t}\n\n\tchannel, err := client.Channel()\n\tif err != nil {\n\t\t// Handle error...\n\t}\n\n\t// Publish and/or receive messages using your channel.\n\n}\n```\n\n## License\n\nThis is Free Software, released under the [`MIT License`][license-url].\n\n## Contributing\n\n* Fix [bugs](https://github.com/ulule/amqpx/issues)\n* Fork the [project](https://github.com/ulule/amqpx)\n* Submit new [idea](https://github.com/ulule/amqpx/issues)\n* Ping us on twitter:\n  * [@nleof](https://twitter.com/nleof)\n  * [@novln_](https://twitter.com/novln_)\n  * [@oibafsellig](https://twitter.com/oibafsellig)\n  * [@thoas](https://twitter.com/thoas)\n\n**Don't hesitate ;)**\n\n[godoc-url]: https://godoc.org/github.com/ulule/amqpx\n[godoc-img]: https://godoc.org/github.com/ulule/amqpx?status.svg\n[license-img]: https://img.shields.io/badge/license-MIT-blue.svg\n[license-url]: LICENSE\n[circle-url]: https://circleci.com/gh/ulule/amqpx/tree/master\n[circle-img]: https://circleci.com/gh/ulule/amqpx.svg?style=shield\u0026circle-token=a76e635936a3dc466d8ee83d9c03524598bae4b8\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fulule%2Famqpx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fulule%2Famqpx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fulule%2Famqpx/lists"}