ShadowySpirits commented on code in PR #5575:
URL: https://github.com/apache/rocketmq/pull/5575#discussion_r1034471391


##########
proxy/src/main/java/org/apache/rocketmq/proxy/grpc/v2/client/ClientActivity.java:
##########
@@ -413,14 +417,48 @@ protected class ConsumerIdsChangeListenerImpl implements 
ConsumerIdsChangeListen
 
         @Override
         public void handle(ConsumerGroupEvent event, String group, Object... 
args) {
-            if (event == ConsumerGroupEvent.CLIENT_UNREGISTER) {
-                if (args == null || args.length < 1) {
+            switch (event) {
+                case CLIENT_UNREGISTER:
+                    processClientUnregister(group, args);
+                    break;
+                case REGISTER:
+                    processClientRegister(group, args);
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        protected void processClientUnregister(String group, Object... args) {
+            if (args == null || args.length < 1) {
+                return;
+            }
+            if (args[0] instanceof ClientChannelInfo) {
+                ClientChannelInfo clientChannelInfo = (ClientChannelInfo) 
args[0];
+                if (ChannelHelper.isRemote(clientChannelInfo.getChannel())) {
                     return;
                 }
-                if (args[0] instanceof ClientChannelInfo) {
-                    ClientChannelInfo clientChannelInfo = (ClientChannelInfo) 
args[0];
-                    
grpcChannelManager.removeChannel(clientChannelInfo.getClientId());
-                    
grpcClientSettingsManager.removeClientSettings(clientChannelInfo.getClientId());
+                GrpcClientChannel removedChannel = 
grpcChannelManager.removeChannel(clientChannelInfo.getClientId());
+                log.info("remove grpc channel when client unregister. 
group:{}, clientChannelInfo:{}, removed:{}",
+                    group, clientChannelInfo, removedChannel != null);
+            }
+        }
+
+        protected void processClientRegister(String group, Object... args) {
+            if (args == null || args.length < 2) {
+                return;
+            }
+            if (args[1] instanceof ClientChannelInfo) {
+                ClientChannelInfo clientChannelInfo = (ClientChannelInfo) 
args[1];
+                Channel channel = clientChannelInfo.getChannel();
+                if (ChannelHelper.isRemote(channel)) {
+                    // save settings from channel sync from other proxy
+                    Settings settings = 
GrpcClientChannel.parseChannelExtendAttribute(channel);

Review Comment:
   This looks weird, settings are parsed from the channel but 
grpcClientSettingsManager is an argument to build Channel. 
   @xdkxlk Do we have a cleaner way to resolve this circular dependency?



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