https://github.com/sysulq/rsmq-go
Go implementation of the Message Queue based on Redis Streams.
https://github.com/sysulq/rsmq-go
at-least-once delay-queue go message-queue opentelemetry ratelimit redis redis-streams retry streams
Last synced: 3 months ago
JSON representation
Go implementation of the Message Queue based on Redis Streams.
- Host: GitHub
- URL: https://github.com/sysulq/rsmq-go
- Owner: sysulq
- License: mit
- Created: 2024-08-08T02:34:54.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-01T01:50:43.000Z (3 months ago)
- Last Synced: 2025-07-01T02:38:53.191Z (3 months ago)
- Topics: at-least-once, delay-queue, go, message-queue, opentelemetry, ratelimit, redis, redis-streams, retry, streams
- Language: Go
- Homepage: https://pkg.go.dev/github.com/sysulq/rsmq-go
- Size: 499 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
rsmq-go
===[](https://github.com/sysulq/rsmq-go/actions/workflows/go.yml)
[](https://codecov.io/github/sysulq/rsmq-go)Go implementation of the Message Queue based on Redis Streams.

Why
---- High performance and low latency
- Easy to use and maintain with RedisFeatures
---- Add message to the queue
- Consume message from the queue
- Auto-acknowledgment of message
- Message delivery delay with specific timestamp
- Message retry ability
- Dead letter queue after retry limit
- Auto clean idle consumer
- Pending message processing
- Distributed rate limiting
- Tag filter for message
- OpenTelemetry instrumentationInstallation
---```bash
go get github.com/sysulq/rsmq-go
```Example
---```go
package rsmq_testimport (
"context"
"encoding/json"
"fmt"
"log"
"time""github.com/redis/go-redis/v9"
"github.com/sysulq/rsmq-go"
)func Example_produceAndConsume() {
cc := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
})queue := rsmq.New(rsmq.Options{
Client: cc,
Topic: "example",
ConsumeOpts: rsmq.ConsumeOpts{
ConsumerGroup: "task_group",
AutoCreateGroup: true,
MaxConcurrency: 1,
},
})
defer queue.Close()// Produce tasks
for i := 0; i < 10; i++ {
task := &rsmq.Message{
Payload: json.RawMessage(fmt.Sprintf(`{"message": "Hello %d"}`, i)),
}err := queue.Add(context.Background(), task)
if err != nil {
log.Printf("Failed to enqueue task: %v", err)
}
}// Consume tasks
go func() {
err := queue.Consume(
context.Background(),
func(ctx context.Context, task *rsmq.Message) error {
var payload map[string]interface{}
_ = json.Unmarshal(task.Payload, &payload)
fmt.Printf("Processing task, payload: %v\n", payload)return nil
},
)
if err != nil {
log.Fatalf("Error consuming tasks: %v", err)
}
}()time.Sleep(time.Second)
// Output:
// Processing task, payload: map[message:Hello 0]
// Processing task, payload: map[message:Hello 1]
// Processing task, payload: map[message:Hello 2]
// Processing task, payload: map[message:Hello 3]
// Processing task, payload: map[message:Hello 4]
// Processing task, payload: map[message:Hello 5]
// Processing task, payload: map[message:Hello 6]
// Processing task, payload: map[message:Hello 7]
// Processing task, payload: map[message:Hello 8]
// Processing task, payload: map[message:Hello 9]
}
```