megarajtm edited a comment on issue #515:
URL: 
https://github.com/apache/pulsar-client-go/issues/515#issuecomment-833636150


   **Proposed fix** : In `runEventsLoop`, have a seperate go-routine working on 
`connectClosedCh` channel. This was `eventsChan` is never blocked. 
   
   ```
   func (p *partitionProducer) runEventsLoop() {
        go func() {
                for {
                        select {
                        case <-p.closeCh:
                                return
                        case <-p.connectClosedCh:
                                p.log.Debug("runEventsLoop will reconnect")
                                p.reconnectToBroker()
                        }
                }
        }()
        for {
                select {
                case i := <-p.eventsChan:
                        switch v := i.(type) {
                        case *sendRequest:
                                p.internalSend(v)
                        case *flushRequest:
                                p.internalFlush(v)
                        case *closeProducer:
                                p.internalClose(v)
                                return
                        }
                case <-p.batchFlushTicker.C:
                        if p.batchBuilder.IsMultiBatches() {
                                p.internalFlushCurrentBatches()
                        } else {
                                p.internalFlushCurrentBatch()
                        }
                }
        }
   }
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to