After reading Joe's weblog post about DWR & Jetty continuations work:
http://getahead.org/blog/joe/2007/03/01/what_is_the_hardest_coding_problem_you_ever_tackled.htmlI decided to try again to use ReverseAjax with Jetty 1.6 and the
latest DWR from CVS.
If I just have a single connection with the long running connection,
then the data doesn't get sent to me until the connection timeout,
which was upped from 30 seconds to 60 seconds, so things look worse!
However (long story on how I figured this out), if I add an empty
method on my DWR object, and constantly poll (every 0.5 seconds)
calling them method, then the data on the reverse-ajax connection is
received immediately. I assume this has something to do with the
server load monitor & such (not familiar with the code base)?
Details:
I have an class exposed by DWR (from Spring) that has the following methods:
private void test() {
if (this.serverContext == null) {
this.serverContext =
ServerContextFactory.get(WebContextFactory.get().getServletContext());
Thread test = new Thread() {
public void run() {
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// do nothing
}
final ScriptBuffer script = new ScriptBuffer();
script.appendScript("test(");
script.appendData(System.currentTimeMillis());
script.appendScript(");");
// Loop over all the users on the current page
final Collection<ScriptSession> sessions =
AjaxDemonstrationService.this.serverContext.getAllScriptSessions();
for (final ScriptSession session : sessions) {
session.addScript(script);
}
}
test.start();
}
public void ping() {
if (this.serverContext == null) {
this.serverContext =
ServerContextFactory.get(WebContextFactory.get().getServletContext());
}
}
On the page I have something like this (from memory of testing code
left at work):
<script type="text/javascript">
function init() {
dwr.engine.setActiveReverseAjax(true);
MyDWRObject.ping(loop);
}
var loop = function() {
setTimeout("MyDWRObject.test(loop)", 500);
}
function test(test) {
alert(test);
}
</script>
If I get rid of the loop part, then it takes 60 seconds before my test
function is called. With the loop, I get results immediately. Any
advice on something else I should try? If not, and it's something
that can be fixed in DWR, I hope this provides enough information to
help.
--
Stephen Duncan Jr
www.stephenduncanjr.com
---------------------------------------------------------------------
To unsubscribe, e-mail:
users-unsubscribe@...
For additional commands, e-mail:
users-help@...