poorbarcode opened a new pull request, #15490: URL: https://github.com/apache/pulsar/pull/15490
### Motivation Currently, the Pulsar client keeps the connection even if no producers or consumers use this connection. If a client produces messages to topic A and we have 3 brokers 1, 2, 3. Due to the bundle unloading(loadmanager) topic ownership will change from A to B and finally to C. For now, the client side will keep 3 connections to all 3 brokers. We can optimize this part to reduce the broker side connections, the client should close the unused connections. ### Modifications Add a scheduled task to check for and release unwanted connections ### Verifying this change - ConnectionPool - Add filed : `maxIdleSeconds` - After constructor, add A scheduled task at startup - PulsarClientImpl - Provides a function to verify that the connection is still in use Specific task execution process: 1. If connection is not still in use, mark it is idle. 2. If A is already marked as idle, release if the free time exceeds `maxIdleSeconds` 3. If A is already marked as idle, the flag will be cleared when it is used again ### Documentation - [ ] `doc-required` - [ ] `no-need-doc` - [ ] `doc` - [x] `doc-added` -- 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: commits-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org