« Return to Thread: Jetty and Reverse Ajax Performance

Re: Jetty and Reverse Ajax Performance

by jrduncans :: Rate this Message:

Reply to Author | View in Thread

In case you didn't see it at the bottom of the e-mail, the zip link is here: http://www.nabble.com/file/7064/dwrtest.zip

-Stephen

jrduncans wrote:
I'm attempting to attach a zip file with a simple project showing off my problem.  I'm posting through Nabble at the moment, so hopefully the file will come through...

It's a Maven project.  You can run it by:

mvn assembly:directory
java -jar target/dwrtest-1.0-SNAPSHOT/dwrtest-1.0-SNAPSHOT/dwrtest-1.0-SNAPSHOT.jar

Or through eclipse after running mvn eclipse:eclipse

- Stephen

Joe Walker-3 wrote:
So the ping is simply giving at alternate way for DWR to send the data back.
Jetty is working just fine for me, it's one of my test cases.

Do you have firebug installed?

Could you turn the ping off (if you have a look at the XHR traces in the
console you'll see them carrying the reverse ajax traffic)
Could you turn DWR debug on so you can see the reverse ajax debug on the way
out (there is an example log4j file in the war that has an example IIRC)
The verify that jetty thinks it has sent the script, but that the browser
has not done anything about it.

Thanks,

Joe.


On 3/8/07, Stephen Duncan <stephen.duncan@gmail.com> wrote:
>
> 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.html
> I 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@dwr.dev.java.net
> For additional commands, e-mail: users-help@dwr.dev.java.net
>
>
dwrtest.zip

 « Return to Thread: Jetty and Reverse Ajax Performance