Jetty now has available an asynchronous implementation for BlazeDS which uses Jetty 7 portable continuations.
BlazeDS is an open source serverside web messaging technology. It provides real-time data push to flex/flash clients using techniques, such as polling and streaming, to provide a richer and more responsive experience. The asynchronous implementation works for HTTP polling, and was tested against BlazeDS 3.2.0.
While the techniques BlazeDS use make clients more responsive, they also increase the load on the server by forcing it to hold a thread for idle clients. The advantage of using Jetty continuations with BlazeDS is that it lets your flash clients wait for a response without holding a thread the entire time, greatly increasing scalability. Jetty 7 style continuations are also portable; webapps coded to use the continuations work async on Jetty or any Servlet 3.0 container, and blocking on any Servlet 2.5 container. Greg explains the benefits of (Jetty 7) continuations better than I could.
To use the asynchronous BlazeDS implementation with one of your applications, go through these quick steps:

  1. Drop jetty-blazeds.jar into your webapp’s classpath
  2. Enable continuations, if you’re using a non-Jetty-7 servlet container:
    • Make sure jetty-continuation-7.jar is on your classpath. Download the latest Jetty distribution from http://www.eclipse.org/jetty/downloads.php and drop lib/jetty-continuation-7*.jar into your webapp’s classpath.
    • Place org.eclipse.jetty.continuation.ContinuationFilter in front of your MessageBrokerServlet. The ContinuationFilter makes it possible for other containers, and even servlet 2.5 containers, to use jetty-7-style portable continuations, which we use as a portability layer on top of asynchronous servlets.

      <!-- Continuation Filter, to enable jetty-7 continuations -->
      <filter>
      <filter-name>ContinuationFilter</filter-name>
      <filter-class>org.eclipse.jetty.continuation.ContinuationFilter</filter-class>
      </filter>
      <filter-mapping>
      <filter-name>ContinuationFilter</filter-name>
      <url-pattern>/messagebroker/*</url-pattern>
      </filter-mapping>

       

  3. Modify your services-config.xml to use Jetty’s AsyncAMFEndpoint instead of AMFEndpoint. AsyncAMFEndpoint uses the same options as AMFEndpoint, e.g.,

    <channel-definition id="my-async-amf" class="mx.messaging.channels.AMFChannel">
    <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amfasync"
    class="org.mortbay.jetty.asyncblazeds.AsyncAMFEndpoint"/>
    <properties>
    <polling-enabled>true</polling-enabled>
    <polling-interval-seconds>0</polling-interval-seconds>
    <max-waiting-poll-requests>10</max-waiting-poll-requests>
    <wait-interval-millis>30000</wait-interval-millis>
    <client-wait-interval-millis>250</client-wait-interval-millis>
    </properties>
    </channel-definition>

     

Source code is available in svn, and you can check it out and build it:

$ svn co http://svn.codehaus.org/jetty/jetty/trunk/jetty-blazeds/
$ cd jetty-blazeds
$ mvn install


2 Comments

Andrew · 03/08/2009 at 17:05

Thank you for great post. I have tried and it works just fine.

Ernesto Ortiz · 03/06/2011 at 22:02

Thanks for the info, this really helps a lot.
Do you know if this librairies works for blaze 4?

Comments are closed.