natsio/jetstream_queue.go

24 lines
519 B
Go
Raw Normal View History

2021-12-02 03:29:52 +00:00
package natsio
import (
"errors"
"fmt"
"github.com/nats-io/nats.go"
)
// QueueSubscribe ...
2022-12-04 15:10:05 +00:00
func (js JetStream) QueueSubscribe(subject, queueName string, cb nats.MsgHandler) error {
2022-12-15 10:34:47 +00:00
_, err := js.instance.QueueSubscribe(subject, queueName, cb)
2021-12-02 03:29:52 +00:00
if err != nil {
2022-12-15 10:34:47 +00:00
msg := fmt.Sprintf("[natsio.JetStream] queue subscribe with subject #%s error: %s", subject, err.Error())
2021-12-02 03:29:52 +00:00
return errors.New(msg)
}
2022-12-15 10:34:47 +00:00
2022-12-15 11:04:03 +00:00
if js.cfg.Debug {
2022-12-15 14:23:28 +00:00
fmt.Printf("[natsio.JetStream] queue subscribe to subject #%s \n", subject)
2022-12-15 10:34:47 +00:00
}
2021-12-02 03:29:52 +00:00
return nil
}