tech4gk opened a new issue #614: URL: https://github.com/apache/pulsar-client-go/issues/614
Question refers to the implementation of [connection_pool.go](https://github.com/apache/pulsar-client-go/blob/master/pulsar/internal/connection_pool.go) Expected Behavior: Based on a typical connection pool implementation, since there is no release method, When client calls the Close() method, the expectation is to release the connection to the connection pool. Actual Behavior: Client deletes the connection from the connection pool and it closes the connection, which as per code, "Close closes the connection by closing underlying socket connection and closeCh. This also triggers callbacks to the ConnectionClosed listeners." The side effect of this is, when the producer code, defers the close connection call, when the function goes out of scope, it closes the underlying connection too. This can cause performance issues, if the connection gets constructed and destroyed with in the same func. (as per the example code) Similar question around the producer implementation too as found in [producer.go](https://github.com/apache/pulsar-client-go/blob/master/pulsar/producer.go) Suggestion: 1. Need better documentation on how connection pool works. 2. Based on the sample code provided on example's [producer.go](https://github.com/apache/pulsar-client-go/blob/master/examples/producer/producer.go), to avoid client connection creation and destruction. is the following recommended a. Create the client once when the client app initialize, with the MaxConnectionsPerBroker setting to a preferred configuration b. Create the producer or consumer once when the client app initializes c. Call the close method on producer when the client app shuts down d. Call the close method on Client when the client app shuts down If the above sounds like a good approach, can we please have the example code fixed, to reflect this change as it can set a better model for the developers. -- 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]
