只需让线程睡眠,就可以在Restlet中实现长轮询吗? [英] Can long-polling be achieved in Restlet by just making the thread sleep?

查看:146
本文介绍了只需让线程睡眠,就可以在Restlet中实现长轮询吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我让线程进入睡眠状态,那么在为特定资源(即 ServerResource )发出 GET 请求时模拟长轮询)会发生什么?框架是否支持此功能?从Java EE的角度来看,有什么副作用?它是否可以很好地扩展Tomcat(或任何其他服务器?)

When making a GET request for a particular resource (i.e. ServerResource) if I put the thread to sleep (to simulate long-polling) what would happen? Does the framework support this? From a Java EE standpoint what are the side-effects? Does it scale well with Tomcat (or any other server?)

是否有任何人试图通过使请求线程休眠来使用Restlet实现长轮询?

Has any-one tried implementing long-polling using Restlet by just making the request thread sleep?

似乎restlet不支持彗星风格的Web应用程序,因此可以说是 hack 的问题。

It seems restlet has no support for comet-style web applications and hence the question of such a hack, so to speak.

推荐答案

只要您不需要大量并发连接就可以阻止线程,这样会导致可伸缩性问题。

Blocking a thread is possible as long as you don't need a huge number of concurrent connections in which case this will cause a scalability issue.

在用于JavaSe的Restlet Framework版本2.1中,内部非阻塞NIO连接器添加了这样的功能(使用有限的线程池处理任意数量的连接),即使它尚未完全稳定并记录在案。

In version 2.1 of the Restlet Framework edition for JavaSe, the internal non-blocking NIO connector has added such capabilities (handling any number of connections with a limited thread pool) even though it isn't fully stable and documented yet.

这篇关于只需让线程睡眠,就可以在Restlet中实现长轮询吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆