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.

преди 6 години
преди 6 години
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Sentinel Dubbo Adapter
  2. > Note: 中文文档请见[此处](https://github.com/alibaba/Sentinel/wiki/%E4%B8%BB%E6%B5%81%E6%A1%86%E6%9E%B6%E7%9A%84%E9%80%82%E9%85%8D#dubbo)。
  3. Sentinel Dubbo Adapter provides service consumer filter and provider filter
  4. for [Dubbo](http://dubbo.io/) services.
  5. To use Sentinel Dubbo Adapter, you can simply add the following dependency to your `pom.xml`:
  6. ```xml
  7. <dependency>
  8. <groupId>com.alibaba.csp</groupId>
  9. <artifactId>sentinel-dubbo-adapter</artifactId>
  10. <version>x.y.z</version>
  11. </dependency>
  12. ```
  13. The Sentinel filters are **enabled by default**. Once you add the dependency,
  14. the Dubbo services and methods will become protected resources in Sentinel,
  15. which can leverage Sentinel's flow control and guard ability when rules are configured.
  16. Demos can be found in [sentinel-demo-dubbo](https://github.com/alibaba/Sentinel/tree/master/sentinel-demo/sentinel-demo-dubbo).
  17. If you don't want the filters enabled, you can manually disable them. For example:
  18. ```xml
  19. <dubbo:consumer filter="-sentinel.dubbo.consumer.filter"/>
  20. <dubbo:provider filter="-sentinel.dubbo.provider.filter"/>
  21. ```
  22. For more details of Dubbo filter, see [here](https://dubbo.incubator.apache.org/#/docs/dev/impls/filter.md?lang=en-us).
  23. ## Dubbo resources
  24. The resource for Dubbo services has two granularities: service interface and service method.
  25. - Service interface:resourceName format is `interfaceName`,e.g. `com.alibaba.csp.sentinel.demo.dubbo.FooService`
  26. - Service method:resourceName format is `interfaceName:methodSignature`,e.g. `com.alibaba.csp.sentinel.demo.dubbo.FooService:sayHello(java.lang.String)`
  27. ## Flow control based on caller
  28. In many circumstances, it's also significant to control traffic flow based on the **caller**.
  29. For example, assuming that there are two services A and B, both of them initiate remote call requests to the service provider.
  30. 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).
  31. Sentinel Dubbo Adapter will automatically resolve the Dubbo consumer's *application name* as the caller's name (`origin`),
  32. and will bring the caller's name when doing resource protection.
  33. If `limitApp` of flow rules is not configured (`default`), flow control will take effects on all callers.
  34. If `limitApp` of a flow rule is configured with a caller, then the corresponding flow rule will only take effect on the specific caller.
  35. > Note: Dubbo consumer does not provide its Dubbo application name when doing RPC,
  36. so developers should manually put the application name into *attachment* at consumer side,
  37. then extract it at provider side. Sentinel Dubbo Adapter has implemented a filter (`DubboAppContextFilter`)
  38. where consumer can carry application name information to provider automatically.
  39. If the consumer does not use Sentinel Dubbo Adapter but requires flow control based on caller, developers can manually put the application name into attachment with the key `dubboApplication`.
  40. ## Global fallback
  41. Sentinel Dubbo Adapter supports global fallback configuration.
  42. The global fallback will handle exceptions and give replacement result when blocked by
  43. flow control, degrade or system load protection. You can implement your own `DubboFallback` interface
  44. and then register to `DubboFallbackRegistry`. If no fallback is configured, Sentinel will wrap the `BlockException`
  45. then directly throw it out.
  46. Besides, we can also leverage [Dubbo mock mechanism](http://dubbo.apache.org/#!/docs/user/demos/local-mock.md?lang=en-us) to provide fallback implementation of degraded Dubbo services.