{"id":36832275,"url":"https://github.com/defensestation/gobroker","last_synced_at":"2026-01-12T14:15:27.671Z","repository":{"id":65253469,"uuid":"543477902","full_name":"defensestation/gobroker","owner":"defensestation","description":"go wrapper for rabbitmq broker","archived":false,"fork":false,"pushed_at":"2025-03-27T12:04:18.000Z","size":74,"stargazers_count":16,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T12:32:41.033Z","etag":null,"topics":["aws","broker","rabbitmq"],"latest_commit_sha":null,"homepage":"","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/defensestation.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2022-09-30T07:23:47.000Z","updated_at":"2025-02-28T20:40:17.000Z","dependencies_parsed_at":"2024-04-15T21:34:01.226Z","dependency_job_id":"d1d620fa-cb77-465f-aec5-e1cf2e0a5ff9","html_url":"https://github.com/defensestation/gobroker","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/defensestation/gobroker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defensestation%2Fgobroker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defensestation%2Fgobroker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defensestation%2Fgobroker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defensestation%2Fgobroker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/defensestation","download_url":"https://codeload.github.com/defensestation/gobroker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defensestation%2Fgobroker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28340386,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T12:22:26.515Z","status":"ssl_error","status_checked_at":"2026-01-12T12:22:10.856Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["aws","broker","rabbitmq"],"created_at":"2026-01-12T14:15:27.033Z","updated_at":"2026-01-12T14:15:27.657Z","avatar_url":"https://github.com/defensestation.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GoBroker v2\n\nGoBroker is a unified messaging broker library for Go that provides a consistent API for working with multiple message broker systems, including RabbitMQ, Redis pub/sub, and Amazon MQ.\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/defensestation/gobroker.svg)](https://pkg.go.dev/github.com/defensestation/gobroker)\n\n## Features\n\n- **Unified API**: Consistent interface for publishing and subscribing across different broker implementations\n- **Multiple Backends**: Support for RabbitMQ, Redis pub/sub, and Amazon MQ\n- **Connection Management**: Automatic connection establishment, error handling, and reconnection\n- **Channel Pooling**: Efficient channel management with pooling and reuse\n- **Error Handling**: Comprehensive error handling and recovery\n- **Auto-Reconnect**: Automatic reconnection on connection failures\n\n## Installation\n\n```bash\ngo install github.com/defensestation/gobroker/v2\n```\n\n## Dependencies\n\n- [amqp091-go](https://github.com/rabbitmq/amqp091-go): RabbitMQ client\n- [redis/go-redis/v9](https://github.com/redis/go-redis/v9): Redis client\n- [go-stomp/stomp/v3](https://github.com/go-stomp/stomp): STOMP client for Amazon MQ\n\n\n## Quick Start\n\n### Creating a Broker\n\n```go\n// RabbitMQ broker\nrabbitBroker := gobroker.NewBroker(\"localhost\", gobroker.BrokerTypeRabbitMQ, \u0026gobroker.EndpointOptions{\n    Username: \"guest\",\n    Password: \"guest\",\n    Port:     \"5672\",\n})\ndefer rabbitBroker.Close()\n\n// Redis broker\nredisBroker := gobroker.NewBroker(\"localhost\", gobroker.BrokerTypeRedis, \u0026gobroker.EndpointOptions{\n    Password: \"\",\n    Port:     \"6379\",\n    DB:       0,\n})\ndefer redisBroker.Close()\n\n// Amazon MQ broker\namazonMQBroker := gobroker.NewBroker(\"admin:password@mq-broker.example.com:61613\", gobroker.BrokerTypeAmazonMQ)\ndefer amazonMQBroker.Close()\n```\n\n### Publishing Messages\n\n```go\n// Create a message\nmessage := map[string]interface{}{\n    \"id\":        123,\n    \"content\":   \"Hello world!\",\n    \"timestamp\": time.Now().Unix(),\n}\n\n// Publish using the unified API\nerr := rabbitBroker.Publish(\"my-exchange.user.created\", message)\nerr = redisBroker.Publish(\"user:created\", message)\nerr = amazonMQBroker.Publish(\"/queue/user-events\", message)\n```\n\n### Subscribing to Messages\n\n```go\n// Subscribe using the unified API\nerr := rabbitBroker.Subscribe(\"my-exchange.user.created\", func(data []byte) {\n    fmt.Printf(\"Received RabbitMQ message: %s\\n\", string(data))\n}, \"my-queue\")\n\nerr = redisBroker.Subscribe(\"user:created\", func(data []byte) {\n    fmt.Printf(\"Received Redis message: %s\\n\", string(data))\n})\n\nerr = amazonMQBroker.Subscribe(\"/queue/user-events\", func(data []byte) {\n    fmt.Printf(\"Received Amazon MQ message: %s\\n\", string(data))\n})\n```\n\n## Broker-Specific Usage\n\n### RabbitMQ\n\nRabbitMQ implementation supports topics in the format `exchange.routekey`.\n\n```go\n// Creating an exchange\nexchange, err := rabbitBroker.BuildExchange(\"user-events\", \u0026gobroker.ExchangeOptions{\n    Type:       \"topic\",\n    Durable:    true,\n    AutoDelete: false,\n})\n\n// Publishing directly to an exchange\nerr = exchange.Publish(\"user.created\", message)\n\n// Queue declare and bind\nqueueName, err := rabbitBroker.QueueDeclareAndBind(\"user-events\", \"user.created\", \"user-created-queue\")\n```\n\n### Redis\n\nRedis implementation uses channel names as topics.\n\n```go\n// Multiple channel subscription\nerr = redisBroker.RunRedisConsumer([]string{\"user:created\", \"user:updated\"}, func(data []byte) {\n    fmt.Printf(\"Received Redis message: %s\\n\", string(data))\n})\n```\n\n### Amazon MQ\n\nAmazon MQ implementation (using STOMP) uses destinations as topics.\n\n```go\n// Using queues\nerr = amazonMQBroker.PublishToAmazonMQQueue(\"/queue/user-events\", message)\n\n// Using topics\nerr = amazonMQBroker.PublishToAmazonMQQueue(\"/topic/user-events\", message)\n```\n\n## Advanced Usage\n\n### Connection Management\n\n```go\n// Get specific connection\nconn, err := rabbitBroker.GetConnection(gobroker.PublishConnection)\n\n// Get specific channel\nch, err := conn.GetChannel()\n\n// Get specific channel by ID\nch, err := conn.GetChannel(5)\n```\n\n### Error Handling\n\n```go\n// All operations return errors that should be checked\nif err := broker.Publish(\"topic\", message); err != nil {\n    log.Printf(\"Failed to publish message: %v\", err)\n}\n```\n\n### Connection Options\n\n```go\n// RabbitMQ with TLS\nrabbitBroker := gobroker.NewBroker(\"secure-rabbit.example.com\", gobroker.BrokerTypeRabbitMQ, \u0026gobroker.EndpointOptions{\n    Protocol: \"amqps\", // Use AMQPS protocol for TLS\n    Username: \"user\",\n    Password: \"pass\",\n    Port:     \"5671\",  // Secure port\n})\n\n// Redis with authentication and database selection\nredisBroker := gobroker.NewBroker(\"redis.example.com\", gobroker.BrokerTypeRedis, \u0026gobroker.EndpointOptions{\n    Password: \"secret\",\n    Port:     \"6379\",\n    DB:       3, // Use database 3\n})\n```\n\n## Design Philosophy\n\nGoBroker was designed with the following principles in mind:\n\n1. **Unified Interface**: Consistent API regardless of the underlying broker implementation\n2. **Simplicity**: Easy to use but powerful enough for complex scenarios\n3. **Resilience**: Robust error handling and automatic reconnection\n4. **Performance**: Efficient connection and channel management\n5. **Extensibility**: Easy to add support for additional broker types\n\n## WARNING\n```\nAmazonMQ has not been tested yet.\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\nGoBroker is licensed under the [MIT License](LICENSE.md).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefensestation%2Fgobroker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefensestation%2Fgobroker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefensestation%2Fgobroker/lists"}