gpt4 book ai didi

java - Jetty 7 延续 : How to *not* redispatch the request?

转载 作者:行者123 更新时间:2023-12-02 08:33:51 25 4
gpt4 key购买 nike

我正在使用 Jetty 7 延续来实现一些异步处理。我想做的是开始延续(通过 .suspend()),然后将延续交给其他一些将组成响应的对象,这样效果很好。但是 Jetty 不断将响应(isInitial = false)重新分派(dispatch)给 servlet,而我不希望或不需要这样做,因为响应正在由其他对象处理。

因此,我想找到一种方法来显式在超时或过期时重新分派(dispatch)请求,因为我使用事件驱动的一系列回调来实际生成响应。

最佳答案

请参阅有关 continuation.isInitial() 的文档 - 来自 http://wiki.eclipse.org/Jetty/Feature/Continuations :

Resuming a Request

Once an asynchronous event has occurred, the continuation can be resumed:

void myAsyncCallback(Object results)
{
continuation.setAttribute("results",results);
continuation.resume();
}

When a continuation is resumed, the request is redispatched to the servlet container, almost as if the request had been received again. However during the redispatch, the continuation.isInitial() method returns false and any attributes set by the asynchronous handler are available.

关于java - Jetty 7 延续 : How to *not* redispatch the request?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2481922/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com