qianye1001 opened a new issue, #11080:
URL: https://github.com/apache/rocketmq/issues/11080

   ### Summary
   
   Start `NettyRemotingClient`'s `NettyEventExecutor` only when a 
`ChannelEventListener` is configured.
   
   ### Motivation
   
   On `develop` at `fd2dc2ffc2`, `NettyRemotingClient.start()` unconditionally 
starts `NettyEventExecutor`, even when `channelEventListener` is `null`. The 
connection handlers already guard event submission with a listener null check. 
Consequently, a client without a listener maintains an unused thread polling an 
empty queue every three seconds.
   
   This occurs in `MQClientAPIExt`, which passes a null listener to 
`MQClientAPIImpl`. A Proxy can own several such internal clients, so the unused 
thread cost accumulates per client.
   
   A minimal reproduction is to construct `new NettyRemotingClient(new 
NettyClientConfig())`, call `start()`, and inspect the threads before calling 
`shutdown()`: a `NettyEventExecutor` thread is started without any listener to 
notify.
   
   ### Describe the Solution You'd Like
   
   Guard `nettyEventExecutor.start()` with `channelEventListener != null`. The 
existing `ServiceThread.shutdown()` already safely handles a service that was 
never started.
   
   Clients with a listener should continue to dispatch connection events as 
before. In particular, the ordinary Remoting SDK's default listener must retain 
its immediate heartbeat and rebalance behavior on a broker channel becoming 
active.
   
   ### Describe Alternatives You've Considered
   
   Sharing event executors between clients would require broader changes to 
callback isolation and resource ownership. Avoiding startup when there is no 
listener addresses this case with a local change.
   
   ### Additional Context
   
   This concerns unnecessary startup without a listener. The poll-related 
shutdown delay for active event executors is tracked separately in #10898.
   


-- 
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]

Reply via email to