Router Extensions

Router Extensions

Extension Description

Select one from multiple service providers to call.

Extension Interfaces

  • org.apache.dubbo.rpc.cluster.RouterFactory
  • org.apache.dubbo.rpc.cluster.Router

Known Extensions

  • org.apache.dubbo.rpc.cluster.router.ScriptRouterFactory
  • org.apache.dubbo.rpc.cluster.router.FileRouterFactory
  • org.apache.dubbo.rpc.cluster.router.condition.config.AppRouterFactory
  • org.apache.dubbo.rpc.cluster.CacheableRouterFactory
  • org.apache.dubbo.rpc.cluster.router.condition.ConditionRouterFactory
  • org.apache.dubbo.rpc.cluster.router.mock.MockRouterFactory
  • org.apache.dubbo.rpc.cluster.router.condition.config.ServiceRouterFactory
  • org.apache.dubbo.rpc.cluster.router.tag.TagRouterFactory

Extension Example

Maven project structure:

  1. src
  2. |-main
  3. |-java
  4. |-com
  5. |-xxx
  6. |-XxxRouterFactory.java (implements RouterFactory interface)
  7. |-resources
  8. |-META-INF
  9. |-dubbo
  10. |-org.apache.dubbo.rpc.cluster.RouterFactory (plain text file, content: xxx=com.xxx.XxxRouterFactory)

XxxRouterFactory.java:

  1. package com.xxx;
  2. import org.apache.dubbo.rpc.cluster.RouterFactory;
  3. import org.apache.dubbo.rpc.Invoker;
  4. import org.apache.dubbo.rpc.Invocation;
  5. import org.apache.dubbo.rpc.RpcException;
  6. public class XxxRouterFactory implements RouterFactory {
  7. public Router getRouter(URL url) {
  8. // ...
  9. }
  10. }

META-INF/dubbo/org.apache.dubbo.rpc.cluster.RouterFactory:

  1. xxx=com.xxx.XxxRouterFactory

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)