From 77276b0ae671450c5f42537bf185a0510d393e87 Mon Sep 17 00:00:00 2001 From: Sinh Date: Tue, 18 Oct 2022 11:46:04 +0700 Subject: [PATCH] add queue subscribe --- server_reqres.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server_reqres.go b/server_reqres.go index 8979ab0..7b2d66b 100644 --- a/server_reqres.go +++ b/server_reqres.go @@ -40,6 +40,16 @@ func (sv Server) Subscribe(subject string, cb nats.MsgHandler) (*nats.Subscripti return sub, nil } +// QueueSubscribe ... +func (sv Server) QueueSubscribe(subject, queue string, cb nats.MsgHandler) (*nats.Subscription, error) { + sub, err := sv.instance.QueueSubscribe(subject, queue, cb) + if err != nil { + msg := fmt.Sprintf("[NATS SERVER] - queue subscribe subject %s, queue %s error: %s", subject, queue, err.Error()) + return nil, errors.New(msg) + } + return sub, nil +} + // NewJSONEncodedConn ... func (sv Server) NewJSONEncodedConn() (*JSONEncoder, error) { enc, err := nats.NewEncodedConn(sv.instance, nats.JSON_ENCODER) -- 2.34.1