Add pull subscribe #1

Merged
namhq1989 merged 12 commits from add-pull-subscribe into master 2022-03-18 04:28:50 +00:00
1 changed files with 10 additions and 0 deletions
Showing only changes of commit 941e4c5ca3 - Show all commits

View File

@ -49,6 +49,16 @@ func (js JetStream) PullSubscribe(stream, subject, durable, consumer string) (*n
con, err := js.instance.ConsumerInfo(stream, consumer)
fmt.Println("con", con)
fmt.Println("err", err)
if con == nil {
info, err := js.instance.AddConsumer(stream, &nats.ConsumerConfig{
Durable: durable,
})
if err != nil {
fmt.Println("CONSUMER INFO", info)
} else {
fmt.Println("ADD CONSUMER ERROR", err)
}
}
sub, err := js.instance.PullSubscribe(subject, durable)
if err != nil {