wxbty commented on code in PR #11786:
URL: https://github.com/apache/dubbo/pull/11786#discussion_r1138783505
##########
dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java:
##########
@@ -325,13 +328,25 @@ protected void subscribeURLs(URL url, NotifyListener
listener, Set<String> servi
serviceListeners.put(serviceNamesKey,
serviceInstancesChangedListener);
}
+ ApplicationModel applicationModel = url.getApplicationModel();
+ GlobalMetricsEventMulticaster eventMulticaster =
applicationModel.getBeanFactory().getBean(GlobalMetricsEventMulticaster.class);
+ TimePair timePair = TimePair.start();
+
+ eventMulticaster.publishEvent(new
RegistryEvent.MetricsServiceSubscribeEvent(applicationModel, timePair,
serviceKey));
if (!serviceInstancesChangedListener.isDestroyed()) {
listener.addServiceListener(serviceInstancesChangedListener);
serviceInstancesChangedListener.addListenerAndNotify(url,
listener);
-
serviceDiscovery.addServiceInstancesChangedListener(serviceInstancesChangedListener);
+ try {
+
serviceDiscovery.addServiceInstancesChangedListener(serviceInstancesChangedListener);
+ } catch (Throwable t) {
+ eventMulticaster.publishErrorEvent(new
RegistryEvent.MetricsServiceSubscribeEvent(applicationModel, timePair,
serviceKey));
+ throw t;
+ }
+ eventMulticaster.publishFinishEvent(new
RegistryEvent.MetricsServiceSubscribeEvent(applicationModel, timePair,
serviceKey));
Review Comment:
Will be optimized together later
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]