When using rpc, the client usually only the interface, but sometimes the client also want to perform part of the logic in the client. For example: do ThreadLocal cache, verify parameters, return mock data when call fails., etc.
To solve this problem, you can configure the stub in the API, so that when the client generates the proxy instance, it passes the proxy to the Stub
via the constructor 1, and then you can implement your logic in the stub implementation code.
Configured in the spring configuration file as follows:
or
Provide Stub implementation 2: