seninel部署
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Sentinel Dubbo Adapter
  2. > Note: 中文文档请见[此处](https://github.com/alibaba/Sentinel/wiki/主流框架的适配#dubbo)。
  3. Sentinel Dubbo Adapter provides service consumer filter and provider filter
  4. for [Dubbo](https://dubbo.apache.org/en-us/) services.
  5. **Note: This adapter only supports legacy Dubbo 2.6.x version and below.**
  6. For new Apache Dubbo 2.7.x or above version, please use `sentinel-apache-dubbo-adapter` module instead.
  7. To use Sentinel Dubbo Adapter, you can simply add the following dependency to your `pom.xml`:
  8. ```xml
  9. <dependency>
  10. <groupId>com.alibaba.csp</groupId>
  11. <artifactId>sentinel-dubbo-adapter</artifactId>
  12. <version>x.y.z</version>
  13. </dependency>
  14. ```
  15. The Sentinel filters are **enabled by default**. Once you add the dependency,
  16. the Dubbo services and methods will become protected resources in Sentinel,
  17. which can leverage Sentinel's flow control and guard ability when rules are configured.
  18. Demos can be found in [sentinel-demo-dubbo](https://github.com/alibaba/Sentinel/tree/master/sentinel-demo/sentinel-demo-dubbo).
  19. If you don't want the filters enabled, you can manually disable them. For example:
  20. ```xml
  21. <dubbo:consumer filter="-sentinel.dubbo.consumer.filter"/>
  22. <dubbo:provider filter="-sentinel.dubbo.provider.filter"/>
  23. ```
  24. For more details of Dubbo filter, see [here](http://dubbo.apache.org/en-us/docs/dev/impls/filter.html).
  25. ## Dubbo resources
  26. The resource for Dubbo services has two granularities: service interface and service method.
  27. - Service interface:resourceName format is `interfaceName`,e.g. `com.alibaba.csp.sentinel.demo.dubbo.FooService`
  28. - Service method:resourceName format is `interfaceName:methodSignature`,e.g. `com.alibaba.csp.sentinel.demo.dubbo.FooService:sayHello(java.lang.String)`
  29. ## Flow control based on caller
  30. In many circumstances, it's also significant to control traffic flow based on the **caller**.
  31. For example, assuming that there are two services A and B, both of them initiate remote call requests to the service provider.
  32. If we want to limit the calls from service B only, we can set the `limitApp` of flow rule as the identifier of service B (e.g. service name).
  33. Sentinel Dubbo Adapter will automatically resolve the Dubbo consumer's *application name* as the caller's name (`origin`),
  34. and will bring the caller's name when doing resource protection.
  35. If `limitApp` of flow rules is not configured (`default`), flow control will take effects on all callers.
  36. If `limitApp` of a flow rule is configured with a caller, then the corresponding flow rule will only take effect on the specific caller.
  37. > Note: Dubbo consumer does not provide its Dubbo application name when doing RPC,
  38. > so developers should manually put the application name into *attachment* at consumer side,
  39. > then extract it at provider side. Sentinel Dubbo Adapter has implemented a filter (`DubboAppContextFilter`)
  40. > where consumer can carry application name information to provider automatically.
  41. > If the consumer does not use Sentinel Dubbo Adapter but requires flow control based on caller,
  42. > developers can manually put the application name into attachment with the key `dubboApplication`.
  43. >
  44. > Since 1.8.0, the adapter provides support for customizing origin parsing logic. You may register your own `DubboOriginParser`
  45. > implementation to `DubboAdapterGlobalConfig`.
  46. ## Global fallback
  47. Sentinel Dubbo Adapter supports global fallback configuration.
  48. The global fallback will handle exceptions and give replacement result when blocked by
  49. flow control, degrade or system load protection. You can implement your own `DubboFallback` interface
  50. and then register to `DubboAdapterGlobalConfig`.
  51. If no fallback is configured, Sentinel will wrap the `BlockException` as the fallback result.
  52. Besides, we can also leverage [Dubbo mock mechanism](http://dubbo.apache.org/en-us/docs/user/demos/local-mock.html) to provide fallback implementation of degraded Dubbo services.