mirror of
https://github.com/oarkflow/mq.git
synced 2025-10-05 16:06:55 +08:00
25 lines
574 B
Go
25 lines
574 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/oarkflow/mq"
|
|
)
|
|
|
|
func main() {
|
|
payload := []byte(`{"phone": "+123456789", "email": "abc.xyz@gmail.com", "age": 12}`)
|
|
task := mq.Task{
|
|
Payload: payload,
|
|
}
|
|
publisher := mq.NewPublisher("publish-1", mq.WithBrokerURL(":8081"))
|
|
for i := 0; i < 2; i++ {
|
|
// publisher := mq.NewPublisher("publish-1", mq.WithTLS(true, "./certs/server.crt", "./certs/server.key"))
|
|
err := publisher.Publish(context.Background(), task, "queue1")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
fmt.Println("Async task published successfully")
|
|
}
|