You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "lfc8912 (GitHub)" <gi...@apache.org> on 2019/12/23 09:36:02 UTC

[GitHub] [dubbo-admin] lfc8912 opened issue #564: 同问

同问

_Originally posted by @632657122 in https://github.com/apache/dubbo-admin/issues/541#issuecomment-568378292_

可以使用了 pom中引入
<dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-monitor-default</artifactId>
            <version>2.7.4</version>
        </dependency> 

在启动服务的时候指定生产者或者消费者使用的filter
ProviderConfig pc = new ProviderConfig();
        pc.setFilter("metrics");
        pc.setGroup(DUBBO_REGISTRY_GROUP);
		
		MetricsConfig mc = new MetricsConfig();
		mc.setPort("20880");
		mc.setProtocol("dubbo");
		// 服务提供者暴露服务配置
		ServiceConfig<DemoService> service = new ServiceConfig<DemoService>(); // 此实例很重,封装了与注册中心的连接,请自行缓存,否则可能造成内存和连接泄漏
		service.setApplication(application);
		service.setRegistry(registry); // 多个注册中心可以用setRegistries()
		service.setProtocol(protocol); // 多个协议可以用setProtocols()
		service.setTimeout(10*1000);
		service.setMetrics(mc);
		service.setTimeout(60*1000);
		service.setProvider(pc);
		service.setConfigCenter(configCenter);
		service.setMetadataReportConfig(metadataConfig);
		service.setGroup(DUBBO_APPLICATION_GROUP);
		service.setInterface(DemoService.class);
		service.setRef(demoService);
		service.setVersion("1.0.1");
我这是API方式启动生产者 可根据实际情况转成配置的


[ Full content available at: https://github.com/apache/dubbo-admin/issues/564 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org