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
(subj string, ch chan *Msg, opts ...SubOpt)
| 1537 | // capacity to handle bursts in traffic, for example other Subscribe APIs use a default of 512k capacity in comparison. |
| 1538 | // See important note in Subscribe() |
| 1539 | func (js *js) ChanSubscribe(subj string, ch chan *Msg, opts ...SubOpt) (*Subscription, error) { |
| 1540 | return js.subscribe(subj, _EMPTY_, nil, ch, false, false, opts) |
| 1541 | } |
| 1542 | |
| 1543 | // ChanQueueSubscribe creates channel based Subscription with a queue group. |
| 1544 | // See important note in QueueSubscribe() |