shibd commented on code in PR #1333:
URL: https://github.com/apache/pulsar-client-go/pull/1333#discussion_r1961394423
##########
pulsar/producer_partition.go:
##########
@@ -581,7 +581,8 @@ func (p *partitionProducer) runEventsLoop() {
}
case connectionClosed := <-p.connectClosedCh:
p.log.Info("runEventsLoop will reconnect in producer")
- p.reconnectToBroker(connectionClosed)
+ // reconnect to broker in a new goroutine so that it
won't block the event loop, see issue #1332
+ go p.reconnectToBroker(connectionClosed)
Review Comment:
I didn't say we should introduce new goroutines.
We currently have an
[eventsLoop](https://github.com/apache/pulsar-client-go/blob/4e71a47a4f6174f883905e740ba35f2498494ed1/pulsar/producer_partition.go#L560-L589)
handling like: `sendRequest, cmdRequest, and reconnections` event. I think
this is a reasonable and simple approach, as it simplifies the concurrency
model.
However, the issue now is that we can't timeout messages that haven't
entered the `pendingQueue`.
So, the question is: **can we understand that sendAsync needs to block
before entering the pendingQueue?** Because essentially, the logic of this
method hasn't fully executed. It's not just about converting the user's message
into a sendRequest; there's much more to be done.
If you look at the [Java
implementation](https://github.com/apache/pulsar/blob/1220951ac74fb4742abbbd331d6e751234c47015/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java#L522-L675),
you'll find that Java handles many things in `sendAsync internal`, and before
these logics are processed, the user call is blocked.
As I understand it, the main purpose of sendAsync is to **`avoid waiting for
the broker's response, not to skip all the logic.`**
Of course, the current implementation might use dataChan, and there might be
some details to consider. I haven't checked the code details.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]