1、啟動時檢查 缺省會在啟動時檢查依賴的服務是否可用,不可用時會拋出異常,阻止Spring初始化完成,以便上線時,能及早發現問題,默認check=true。 關閉所有服務的啟動時檢查:(沒有提供者時報錯) <dubbo:consumer check="false" /> 關閉某個服務的啟動時檢查:(沒有提供者時報錯) <dubbo:reference interface="com.foo.BarService" check="false" /> 其它的啟動時檢查還包括:注冊中心 2、直連提供者 在開發及測試環境下,經常需要繞過注冊中心,只測試指定服務提供者,這時候可能需要點對點直連, 點對點直聯方式,將以服務接口為單位,忽略注冊中心的提供者列表。 <dubbo:reference id="xxxService" interface="com.alibaba.xxx.XxxService" url="dubbo://localhost:20890" /> 3、服務分組 當一個接口有多種實現時,可以用group區分。 provider: <dubbo:service group="feedback" interface="com.xxx.IndexService" ref="indexServiceFeedback" /> <dubbo:service group="member" interface="com.xxx.IndexService" ref="indexServiceMember" /> cosumer: <dubbo:reference id="feedbackIndexService" group="feedback" interface="com.xxx.IndexService" /> <dubbo:reference id="memberIndexService" group="member" interface="com.xxx.IndexService" /> 4、多版本 當一個接口實現,出現不兼容升級時,可以用版本號過渡,版本號不同的服務相互間不引用。 一般處理步驟 1)在低壓力時間段,先升級一半提供者為新版本 2)再將所有消費者升級為新版本 3)然后將剩下的一半提供者升級為新版本 <dubbo:service interface="com.foo.BarService" version="1.0.0" /> <dubbo:service interface="com.foo.BarService" version="2.0.0" /> 5、異步調用 可完成並行調用多個遠程服務。異步總是不等待返回。 <dubbo:reference id="fooService" interface="com.alibaba.foo.FooService"> <dubbo:method name="findFoo" async="true" /> </dubbo:reference> 6、延遲暴露 如果你的服務需要Warmup時間,比如初始化緩存,等待相關資源就位等,可以使用delay進行延遲暴露。 <dubbo:provider delay="-1" /> 當然,也可以配置到服務級別,但有些需要地方需要注意。 7、dubbo:protocol屬性 threadpool:線程池類型,可選:fixed/cached ,默認fixed 。 threads :服務線程池大小(固定大小) ,默認為100 payload:請求及響應數據包大小限制,單位:字節,默認為88388608(=8M) 如:<dubbo:protocol name="dubbo" port="27001" threadpool="cached" threads="20"/> ThreadPool fixed 固定大小線程池,啟動時建立線程,不關閉,一直持有。(缺省) cached 緩存線程池,空閑一分鍾自動刪除,需要時重建。 limited可伸縮線程池,但池中的線程數只會增長不會收縮。(為避免收縮時突然來了大流量引起的性能問題)。 8、dubbo:application <dubbo:application name="xxx_service" /> name必填。當前應用名稱,用於注冊中心計算應用間依賴關系,注意:消費者和提供者應用名不要一樣
