natsio/queue.go

21 lines
443 B
Go
Raw Normal View History

2021-10-08 04:23:59 +00:00
package natsio
import (
"errors"
"fmt"
"github.com/nats-io/nats.go"
)
// QueueSubscribe ...
2021-10-08 07:45:07 +00:00
func QueueSubscribe(stream, subject, queueName string, cb nats.MsgHandler) error {
channel := combineStreamAndSubjectName(stream, subject)
_, err := natsJS.QueueSubscribe(channel, queueName, cb)
2021-10-08 04:23:59 +00:00
if err != nil {
2021-10-08 07:45:07 +00:00
msg := fmt.Sprintf("queue subscribe with subject %s error: %s", channel, err.Error())
2021-10-08 04:23:59 +00:00
return errors.New(msg)
}
return nil
}