https://github.com/backaged/steadyrabbit
Stable go rabbitmq client
https://github.com/backaged/steadyrabbit
go go-rabbitmq golang rabbitmq rabbitmq-client
Last synced: about 1 year ago
JSON representation
Stable go rabbitmq client
- Host: GitHub
- URL: https://github.com/backaged/steadyrabbit
- Owner: BackAged
- Created: 2020-11-02T18:14:15.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-19T19:44:42.000Z (over 5 years ago)
- Last Synced: 2025-03-29T19:51:12.444Z (about 1 year ago)
- Topics: go, go-rabbitmq, golang, rabbitmq, rabbitmq-client
- Language: Go
- Homepage:
- Size: 47.9 KB
- Stars: 23
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# steadyrabbit
steadyrabbit is a library for working with rabbitmq
## Usage
```
package main
import (
"context"
"log"
"github.com/BackAged/steadyrabbit"
"github.com/streadway/amqp"
)
func main() {
p, err := steadyrabbit.NewPublisher(&steadyrabbit.Config{
URL: "amqp://localhost",
})
if err != nil {
log.Fatalf("unable to instantiate publisher: %s", err)
}
queueName := "shahin"
if err = p.Publish(context.Background(), queueName, []byte("shahin")); err != nil {
log.Fatalf("unable to publish message: %s", err)
}
c, err := steadyrabbit.NewConsumer(&steadyrabbit.Config{
URL: "amqp://localhost",
Consumer: &steadyrabbit.ConsumerConfig{
QueueConfig: &steadyrabbit.QueueConfig{
QueueName: queueName,
QueueDeclare: true,
QueueDurable: true,
},
},
})
if err != nil {
log.Fatalf("unable to instantiate consumer: %s", err)
}
c.Consume(context.Background(), func(msg amqp.Delivery) error {
log.Println("got message: ", msg)
return msg.Ack(false)
})
}
```
## License
None