From 22afdbddfba27a0ce245174ce6f719574860cdf3 Mon Sep 17 00:00:00 2001 From: Waldemar Quevedo Date: Fri, 16 Sep 2022 07:42:48 -0700 Subject: [PATCH] js: update Chan Subscribe with note about capacity --- js.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/js.go b/js.go index e0022015c..359f3ef16 100644 --- a/js.go +++ b/js.go @@ -1228,6 +1228,9 @@ func (js *js) QueueSubscribeSync(subj, queue string, opts ...SubOpt) (*Subscript } // ChanSubscribe creates channel based Subscription. +// Using ChanSubscribe without buffered capacity is not recommended since +// it will be prone to dropping messages with a slow consumer error. Make sure to give the channel enough +// capacity to handle bursts in traffic, for example other Subscribe APIs use a default of 512k capacity in comparison. // See important note in Subscribe() func (js *js) ChanSubscribe(subj string, ch chan *Msg, opts ...SubOpt) (*Subscription, error) { return js.subscribe(subj, _EMPTY_, nil, ch, false, false, opts)