views:

35

answers:

1

I'd like to be able to set a configurable (by controller/action) request timeout in grails. The objective is to handle a rare high-load failure mode in a deterministic way. For example, I know that if a given controller/action doesn't return in 30 seconds, then something is horribly wrong and I don't want to keep the user hanging.

I'd like to handle this within the application logic if possible, as there might be reasonable recoveries or messaging depending upon the conditions of the event.

Filters don't work because the time might be reached anywhere in the request processing lifecycle.

A: 

I don't think this is easily achievable. You're probably limited to the capabilities of the Servlet container you're using. For example, with tomcat you could set a connectionTimeout. Unfortunately, this may not give you the control that you're asking for since the timeout and response are more at the mercy of the container.

There's probably a way you could do it with background threads, timers, interrupts, and some black magic, but that would probably be an ill-advised thing.

A couple mailing list discussions I found on the topic:

Rob Hruska