Dubbo3 監(jiān)控中心擴展

2022-04-22 11:53 更新

擴展說明

負(fù)責(zé)服務(wù)調(diào)用次和調(diào)用時間的監(jiān)控。

擴展接口

  • org.apache.dubbo.monitor.MonitorFactory
  • org.apache.dubbo.monitor.Monitor

擴展配置

<!-- 定義監(jiān)控中心 -->
<dubbo:monitor address="xxx://ip:port" />

已知擴展

org.apache.dubbo.monitor.support.dubbo.DubboMonitorFactory

擴展示例

Maven 項目結(jié)構(gòu):

src
 |-main
    |-java
        |-com
            |-xxx
                |-XxxMonitorFactoryjava (實現(xiàn)MonitorFactory接口)
                |-XxxMonitor.java (實現(xiàn)Monitor接口)
    |-resources
        |-META-INF
            |-dubbo
                |-org.apache.dubbo.monitor.MonitorFactory (純文本文件,內(nèi)容為:xxx=com.xxx.XxxMonitorFactory)

XxxMonitorFactory.java:

package com.xxx;
 
import org.apache.dubbo.monitor.MonitorFactory;
import org.apache.dubbo.monitor.Monitor;
import org.apache.dubbo.common.URL;
 
public class XxxMonitorFactory implements MonitorFactory {
    public Monitor getMonitor(URL url) {
        return new XxxMonitor(url);
    }
}

XxxMonitor.java:

package com.xxx;
 
import org.apache.dubbo.monitor.Monitor;
 
public class XxxMonitor implements Monitor {
    public void count(URL statistics) {
        // ...
    }
}

META-INF/dubbo/org.apache.dubbo.monitor.MonitorFactory:

xxx=com.xxx.XxxMonitorFactory


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號