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.