问题
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?)
Has any-one tried implementing long-polling using Restlet by just making the request thread sleep?
It seems restlet has no support for comet-style web applications and hence the question of such a hack, so to speak.
回答1:
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.
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.
来源:https://stackoverflow.com/questions/9051723/can-long-polling-be-achieved-in-restlet-by-just-making-the-thread-sleep