From f6d6b5afee8ed28e368429556a5a8ae903add5dd Mon Sep 17 00:00:00 2001 From: Nam Huynh Date: Fri, 18 Mar 2022 10:49:07 +0700 Subject: [PATCH] add check consumer --- jetstream_pubsub.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jetstream_pubsub.go b/jetstream_pubsub.go index 311854e..066db87 100644 --- a/jetstream_pubsub.go +++ b/jetstream_pubsub.go @@ -44,7 +44,12 @@ func (js JetStream) Subscribe(stream, subject string, cb nats.MsgHandler) (*nats // // process each messages // } // -func (js JetStream) PullSubscribe(subject, durable string) (*nats.Subscription, error) { +func (js JetStream) PullSubscribe(stream, subject, durable, consumer string) (*nats.Subscription, error) { + // Check if consumer existed + con, err := js.instance.ConsumerInfo(stream, consumer) + fmt.Println("con", con) + fmt.Println("err", err) + sub, err := js.instance.PullSubscribe(subject, durable) if err != nil { msg := fmt.Sprintf("[NATS JETSTREAM] - pull subscribe subject #%s - durable #%s error: %s", subject, durable, err.Error())