0

Can I configure Glassfish to drop any request that takes longer than 10 seconds to process?

Example: I'm using Glassfish to host my web service. The thread pool is configured to have max 5 connections.

My service has a method that does this:

System.out.println("New request");
Thread.sleep(1000*1000);

I'm creating 5 requests to the service and I see 5 messages "New request" in the log. Then the server stop to respond for a looong time.

In live environment all requests must be processed in less than a second. If it takes more time to process then there is a problem with the request and I want Glassfish to drop such requests but stay alive and serve other requests.

Stan
  • 5,106
  • 1
  • 17
  • 7

1 Answers1

0

Currently I'm using a workaround in the code. At the beginning of my web method I launch a separate thread for request processing with a timeout as it was suggested here: How to timeout a thread

I do not like this solution and still believe that there must be a configuration setting in the Glassfish to apply this logic to all requests, not to just one method.

Community
  • 1
  • 1
Stan
  • 5,106
  • 1
  • 17
  • 7