add check consumer
This commit is contained in:
parent
f6d6b5afee
commit
941e4c5ca3
|
@ -49,6 +49,16 @@ func (js JetStream) PullSubscribe(stream, subject, durable, consumer string) (*n
|
||||||
con, err := js.instance.ConsumerInfo(stream, consumer)
|
con, err := js.instance.ConsumerInfo(stream, consumer)
|
||||||
fmt.Println("con", con)
|
fmt.Println("con", con)
|
||||||
fmt.Println("err", err)
|
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)
|
sub, err := js.instance.PullSubscribe(subject, durable)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue