mirror of
https://github.com/oarkflow/mq.git
synced 2025-10-04 23:52:48 +08:00
u
This commit is contained in:
18
task.go
18
task.go
@@ -2,6 +2,7 @@ package mq
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/oarkflow/json"
|
||||
@@ -93,3 +94,20 @@ func WithDedupKey(key string) TaskOption {
|
||||
t.DedupKey = key
|
||||
}
|
||||
}
|
||||
|
||||
// Add advanced dead-letter queue management
|
||||
func (b *Broker) ReprocessDLQ(queueName string) error {
|
||||
dlqName := queueName + "_dlq"
|
||||
dlq, ok := b.deadLetter.Get(dlqName)
|
||||
if !ok {
|
||||
return fmt.Errorf("dead-letter queue %s does not exist", dlqName)
|
||||
}
|
||||
for {
|
||||
select {
|
||||
case task := <-dlq.tasks:
|
||||
b.NewQueue(queueName).tasks <- task
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user