Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Question regarding Continuation documentation

Hi,

On Tue, Nov 11, 2014 at 10:37 AM, Christoph Läubrich
<laeubi@xxxxxxxxxxxxxx> wrote:
> Hi,
>
> the documentation here suggest:
>
> 'The timeout should be set before the suspend'
> https://wiki.eclipse.org/Jetty/Feature/Continuations#Suspending_a_Request
>
> Is there any way to change the timeout value AFTER a call to suspend? In my
> case I set up all the continuation timout stuff and suspend it, then submit
> ot a background worker. If the worker can't process the request I want to
> set a (shorter) timeout to throttle the client before the next request.

Can you set the timeout *after* you know the worker will be able to
process the request ?
if (submit(work))
    timeout = 30000;
else
    timeout = 1000;
ctx = request.startAsync();
ctx.setTimeout(timeout);

Alternatively, you can startAsync(), submit and return, and the task
can dispatch (perhaps to a different URI, or differentiating using a
request attribute) where you call startAsync() again with the throttle
timeout.

-- 
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.


Back to the top