{"id":16132933,"url":"https://github.com/icpd/rabbitmq","last_synced_at":"2025-03-18T15:30:47.453Z","repository":{"id":149226982,"uuid":"618739043","full_name":"icpd/rabbitmq","owner":"icpd","description":"Wrap RabbitMQ ( amqp091-go ) to enable automatic reconnection in case of disconnection.  针对 RabbitMQ（amqp091-go） 的封装，使其能够断线自动重连","archived":false,"fork":false,"pushed_at":"2023-10-31T16:51:16.000Z","size":43,"stargazers_count":11,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-10T22:35:14.747Z","etag":null,"topics":["amqp091-go","channel","connect","rabbitmq","reconnect"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/icpd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-03-25T07:49:31.000Z","updated_at":"2024-07-02T01:47:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"56c6f9df-0eaf-46ea-aad7-9284bf870c2d","html_url":"https://github.com/icpd/rabbitmq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icpd%2Frabbitmq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icpd%2Frabbitmq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icpd%2Frabbitmq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icpd%2Frabbitmq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/icpd","download_url":"https://codeload.github.com/icpd/rabbitmq/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221713429,"owners_count":16868256,"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":["amqp091-go","channel","connect","rabbitmq","reconnect"],"created_at":"2024-10-09T22:35:18.445Z","updated_at":"2024-10-27T17:53:15.261Z","avatar_url":"https://github.com/icpd.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rabbitmq\n\nWrap `github.com/rabbitmq/amqp091-go` to enable automatic reconnection in case of disconnection.\n\n\n## Feature\n\n- Add automatic reconnection handling\n- Retry sending messages when failed\n- Shield the usage details of `github.com/rabbitmq/amqp091-go` and reduce users' cognitive load.\n\n## Usage\n\n\n### Publish\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/icpd/rabbitmq\"\n)\n\nfunc main() {\n\t// 1. Initialize a rabbitmq object\n\tr := rabbitmq.NewRabbitmq(\n\t\t\"amqp://admin:admin@192.168.2.239:5672\",\n\t\tnil,\n\t)\n\n\t// 2. Create a connection to the rabbitmq service\n\tif err := r.Connect(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// 3. Declare an exchange with the rabbitmq service\n\texchange := rabbitmq.ExchangeOptions{\n\t\tName:    \"example_exchange\",          // Exchange name\n\t\tType:    rabbitmq.ExchangeTypeFanout, // Exchange type\n\t\tDurable: true,                        // Whether it is durable\n\t}\n\tif err := r.Exchange(exchange); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// 4. Send a message to the exchange, not blocking\n\t// Notice: Please ensure that the exchange has been created before publishing a message\n\terr := r.Publish(\n\t\tcontext.Background(),\n\t\t[]byte(fmt.Sprintf(\"hello %d\", i)), // Message body to be sent \n\t\trabbitmq.Exchange(exchange),        // Set the message exchange target\n\t)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tselect {}\n}\n\n```\n\n### Subscribe\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\n\t\"github.com/icpd/rabbitmq\"\n)\n\nfunc main() {\n\t// 1. Initialize a rabbitmq object\n\tr := rabbitmq.NewRabbitmq(\n\t\t\"amqp://admin:admin@192.168.2.239:5672\",\n\t\tnil,\n\t)\n\n\t// 2. Create a connection to the rabbitmq service\n\tif err := r.Connect(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// 3. Exchange configuration\n\texchange := rabbitmq.ExchangeOptions{\n\t\tName:    \"example_exchange\",          // Exchange name\n\t\tType:    rabbitmq.ExchangeTypeFanout, // Exchange type\n\t\tDurable: true,                        // Whether it is durable\n\t}\n\n\t// 4. Create a subscription\n\t// Subscribing and consuming internally starts a goroutine that consumes data so it won't block the main goroutine.\n\terr := r.Subscribe(func(msg []byte) error {\n\t\tlog.Println(\"receive:\", string(msg))\n\t\treturn nil\n\t},\n\t\trabbitmq.Queue(\"example_queue\"), // Set the name of the consumption queue\n\t\trabbitmq.Exchange(exchange),     // Set the exchange that the queue needs to bind to\n\t)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tselect {}\n}\n\n```\nFor more usage examples, please refer to the `_example` directory.\n\n\n## Others\nhttps://github.com/wagslane/go-rabbitmq  \nhttps://github.com/pmorelli92/bunnify\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficpd%2Frabbitmq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficpd%2Frabbitmq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficpd%2Frabbitmq/lists"}