|
|
5 years ago | |
|---|---|---|
| .github/workflows | 5 years ago | |
| examples | 5 years ago | |
| vendor | 5 years ago | |
| LICENSE | 5 years ago | |
| Makefile | 5 years ago | |
| README.md | 5 years ago | |
| channel.go | 5 years ago | |
| consume.go | 5 years ago | |
| go.mod | 5 years ago | |
| go.sum | 5 years ago | |
| logger.go | 5 years ago | |
| publish.go | 5 years ago | |
| table.go | 5 years ago | |
Wrapper of streadway/amqp that provides reconnection logic and sane defaults. Hit the project with a star if you find it useful ⭐
Supported by Qvault
Streadway's AMQP library is currently the most robust and well-supported Go client I'm aware of. It's a fantastic option and I recommend starting there and seeing if it fulfills your needs. Their project has made an effort to stay within the scope of the AMQP protocol. As such, no reconnection logic and few ease-of-use abstractions are provided.
The goal with go-rabbit is to still provide basically all of the nitty-gritty functionality of AMQP, but to make it easier to work with via a higher-level API. Particularly:
Outside of a Go module:
go get github.com/wagslane/go-rabbitmq
consumer, err := rabbitmq.GetConsumer("amqp://user:pass@localhost", true)
if err != nil {
log.Fatal(err)
}
err = consumer.StartConsumers(
func(d rabbitmq.Delivery) bool {
log.Printf("consumed: %v", string(d.Body))
// true to ACK, false to NACK
return true
},
// can pass nil here for defaults
&rabbitmq.ConsumeOptions{
QueueOptions: rabbitmq.QueueOptions{
Durable: true,
},
QosOptions: rabbitmq.QosOptions{
Concurrency: 10,
Prefetch: 100,
},
},
"my_queue",
"routing_key1", "routing_key2",
)
if err != nil {
log.Fatal(err)
}
publisher, returns, err := rabbitmq.GetPublisher("amqp://user:pass@localhost", true)
if err != nil {
log.Fatal(err)
}
err = publisher.Publish(
[]byte("hello, world"),
// leave nil for defaults
&rabbitmq.PublishOptions{
Exchange: "events",
Mandatory: true,
},
"routing_key",
)
if err != nil {
log.Fatal(err)
}
go func() {
for r := range returns {
log.Printf("message returned from server: %s", string(r.Body))
}
}()
Submit an issue (above in the issues tab)
I love help! Contribute by forking the repo and opening pull requests. Please ensure that your code passes the existing tests and linting, and write tests to test your changes if applicable.
All pull requests should be submitted to the main branch.
make test
make fmt
make vet
make lint