seninel部署
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # Sentinel SOFARPC Adapter
  2. Sentinel SOFARPC Adapter provides service provider filter and consumer filter
  3. for [SOFARPC](https://www.sofastack.tech/projects/sofa-rpc) services.
  4. **Note: This adapter supports SOFARPC 5.4.x version and above, and 5.6.x is officially recommended.**
  5. To use Sentinel SOFARPC 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-sofa-rpc-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 SOFARPC 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-sofa-rpc](https://github.com/alibaba/Sentinel/tree/master/sentinel-demo/sentinel-demo-sofa-rpc).
  17. If you don't want the filters enabled, you can manually disable them. For example:
  18. ```java
  19. providerConfig.setParameter("sofa.rpc.sentinel.enabled", "false");
  20. consumerConfig.setParameter("sofa.rpc.sentinel.enabled", "false");
  21. ```
  22. or add setting in `rpc-config.json` file, and its priority is lower than above.
  23. ```json
  24. {
  25. "sofa.rpc.sentinel.enabled": true
  26. }
  27. ```
  28. For more details of SOFARPC filter, see [here](https://www.sofastack.tech/projects/sofa-rpc/custom-filter/).
  29. ## SOFARPC resources
  30. The resource for SOFARPC services has two granularities: service interface and service method.
  31. - Service interface:resourceName format is `interfaceName`,e.g. `com.alibaba.csp.sentinel.demo.sofa.rpc.DemoService`
  32. - Service method:resourceName format is `interfaceName#methodSignature`,e.g. `com.alibaba.csp.sentinel.demo.sofa.rpc.DemoService#sayHello(java.lang.Integer,java.lang.String,int)`
  33. ## Flow control based on caller
  34. In many circumstances, it's also significant to control traffic flow based on the **caller**.
  35. For example, assuming that there are two services A and B, both of them initiate remote call requests to the service provider.
  36. 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).
  37. Sentinel SOFARPC Adapter will automatically resolve the SOFARPC consumer's *application name* as the caller's name (`origin`),
  38. and will bring the caller's name when doing resource protection.
  39. If `limitApp` of flow rules is not configured (`default`), flow control will take effects on all callers.
  40. If `limitApp` of a flow rule is configured with a caller, then the corresponding flow rule will only take effect on the specific caller.
  41. ## Global fallback
  42. Sentinel SOFARPC Adapter supports global fallback configuration.
  43. The global fallback will handle exceptions and give replacement result when blocked by
  44. flow control, degrade or system load protection. You can implement your own `SofaRpcFallback` interface
  45. and then register to `SofaRpcFallbackRegistry`. If no fallback is configured, Sentinel will wrap the `BlockException`
  46. then directly throw it out.