mirror of
https://github.com/oarkflow/mq.git
synced 2025-10-05 16:06:55 +08:00
init: publisher
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/oarkflow/mq"
|
||||
)
|
||||
|
||||
@@ -10,7 +11,7 @@ func main() {
|
||||
consumer := mq.NewConsumer(":8080")
|
||||
consumer.RegisterHandler("queue1", func(ctx context.Context, task mq.Task) mq.Result {
|
||||
fmt.Println("Handling task for queue1:", task.ID)
|
||||
return mq.Result{Payload: task.Payload, MessageID: task.ID}
|
||||
return mq.Result{Payload: []byte(`{"task": 123}`), MessageID: task.ID}
|
||||
})
|
||||
consumer.RegisterHandler("queue2", func(ctx context.Context, task mq.Task) mq.Result {
|
||||
fmt.Println("Handling task for queue2:", task.ID)
|
||||
|
Reference in New Issue
Block a user