@FeignClient can be used as an HTTP proxy to access other microservices nodes, you can replace the @feignclient native URLConnection request mode with Apache HttpClient to allow HTTP requests to go to the HTTP thread pool. With the integration of @feignclient and Hystrix, the Hystrix dashboard can monitor the interface invocation situation in @feignclient and @feignclient the usage of the thread pool.
Here is an example of demo:
1, @FeignClient Interface code is as follows:
@FeignClient (value= "service-a", Fallback=serviceclienthystrix.class)
Public interface ServiceClient {
@RequestMapping (method = requestmethod.get, value = "/add/{id}")
String Add (@PathVariable ("id") Integer ID);
}
2, Serviceclienthystrix.java
@Component
public class Serviceclienthystrix implements serviceclient{
@Override
Public String Add (Integer ID) {
Return "add value from Serviceclienthystrix";
}
}
3. With regard to @feignclient and hystrix integration, the HTTP thread pool is configured as follows:
Hystrix.threadpool. Service instance ID. Parameters
For example, set the thread pool maximum number of threads for httpclient
hystrix.threadpool.service-a.coresize=20//default is Hystrix.threadpool.default.coreSize = 10
hystrix.threadpool.service-a.maximumsize=20//default is Hystrix.threadpool.default.maximumSize = 10
After starting the service, we use the test case to call the interface test continuously, using Hystrix Dashboard Monitor to get the following image monitoring effect:
Remove Hystrix.threadpool. Service Instance ID. Once the parameter is configured, it is monitored again with the test case call interface as shown below:
The size of the poolsize depends on the Hystrix.threadpool. Service instance id.coresize size setting