Home How to get the count of number of active client requests for a GET method
Reply: 1

How to get the count of number of active client requests for a GET method

rookie
1#
rookie Published in 2017-12-07 09:04:02Z

Is there a way to find the number of active client requests currently accessing a GET method(getProducts()) in REST?

What I have is:

@GET
@Path("/products")    
@Produces({ "application/xml" })    
public Response getProducts(){
//My business logic to retrieve products go here

}

Now, I issue a GET request from the browser: http://localhost:8080/v1/products

How to find the number of active client requests currently accessing getProducts() method at any point in time on the server side?

Stanislav Bashkyrtsev
2#
Stanislav Bashkyrtsev Reply to 2017-12-07 09:09:55Z

Pick one:

  • Write a Servlet Listener (implementing ServletRequestListener) that increments and decrements when the request is initialized and destroyed
  • Put the logic of counting directly into getProducts() method
  • Create an AOP advice that wraps getProducts() around and increments/decrements when the method is entered and exited

There are tools already written that can measure the performance (and the request counts). One of them: JETM.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.395385 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO