0

enter image description here

  1. How can I monitor the number of threads B handles, when A calls B

  2. How can I monitor the number of requests from B -> C.

My goal here is to ensure B is able to handle all the concurrent thread requests (say 100), and B is maintaining the same number of concurrent threads (100) when calling C.

Himalay Majumdar
  • 3,883
  • 14
  • 65
  • 94
  • plz read this --> https://stackoverflow.com/questions/47938265/does-spring-create-new-thread-per-request-in-rest-controllers – jps sasadara Jun 20 '21 at 07:05

1 Answers1

0

I am assuming C is Spring REST API. I can answer the 2nd part.

You can configure a custom interceptor in C's servlet.xml

<mvc:interceptors>
    <mvc:interceptor>
        <mvc:mapping path="/URI" />
        <bean class="xxx.ABCInterceptor"/>
    </mvc:interceptor>
</mvc:interceptors> 


public class ABCInterceptor extends HandlerInterceptorAdapter {
    @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
        ......
    }
    @Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) { 
        ......
    }
}

in the postHandle method, you can write the count to a file or DB based on a identifier, which indicates its coming from B.