activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject svn commit: r384188 - in /incubator/activemq/site: Ajax OpenWire+dotNet
Date Wed, 08 Mar 2006 11:47:01 GMT
Author: foconer
Date: Wed Mar  8 03:46:59 2006
New Revision: 384188

Latest HTML dump from the confluence wiki created by wikimesh; see the confluence log for
a detailed 


Modified: incubator/activemq/site/Ajax
--- incubator/activemq/site/Ajax (original)
+++ incubator/activemq/site/Ajax Wed Mar  8 03:46:59 2006
@@ -254,37 +254,88 @@
-<div class="section_1"><h1><a name="Ajax-Introduction"></a>Introduction</h1>
+          <div class="section_1"><h1><a name="Ajax-Introduction"></a>Introduction</h1>
 <p>ActiveMQ supports <span class="nobr"><a href="">Ajax</a></span>
which is an Asychronous Javascript And Xml mechanism for real time web applications. </p>
 <p>Ajax allows a regular DHTML client (with JavaScript and a modern version 5 or later
web browser) to send and receive messages over the web. Ajax support in ActiveMQ builds on
the same basis as the <a href="/REST" title="REST">REST</a> connector for ActiveMQ
which allows any web capable device to send or receive messages over JMS.</p>
 <p>To see Ajax in action, try <a href="/Web+Samples" title="Web Samples">running
the examples</a></p>
-</div><div class="section_1"><h1><a name="Ajax-Howitworks"></a>How
it works</h1>
+</div><div class="section_1"><h1><a name="Ajax-JavascriptAPI"></a>Javascript
-<div class="section_2"><h2><a name="Ajax-SendingJMS"></a>Sending
+<p>The ajax featues of amq are provided on the client side by the <span class="nobr"><a
script.  This script depends on <span class="nobr"><a href="">behaviour</a></span>
and <span class="nobr"><a href="">prototype</a></span>.
 All of these scripts can be loaded with the single script <span class="nobr"><a
as follows:</p>
-<div class="section_3"><h3><a name="Ajax-Clientsideview"></a>Client
side view </h3>
+<div class="code"><div class="codeContent">
+<pre class="code-java">&lt;script type=<span class="code-quote">"text/javascript"</span>
src=<span class="code-quote">"/context/js/<span class="code-keyword">default</span>.js"</span>&gt;&lt;/script&gt;</pre>
-<p>The client side is a web browser using Ajax which means using the JavaScript <span
class="nobr"><a href="">XmlHttpRequest</a></span>
to make calls on the <a href="/REST" title="REST">REST</a> API to send or receive
+<p>Including these scripts results in the creation of a javascript object called <tt>amq</tt>,
which provides the API to send messages and to subscribe to channels and topics.</p>
-<p>This means that the Ajax client can send or receive messages asynchronously from
the users interaction and can easily <em>databind</em> XML messages received with
the HTML DOM to produce some revolutionary applications all with standard DHTML technologies.</p>
+<div class="section_2"><h2><a name="Ajax-Sendingamessage."></a>Sending
a message.</h2>
-<p>The web browser can then render active views of information which can update in
real time.</p>
+<p>All that is required to send a JMS message from the javascript client, is to call
the method:</p>
-<p>If you want to use an existing Ajax library on the browser side we strongly recommend
the <span class="nobr"><a href="">OpenRico</a></span>
library which builds on top of the lower level <span class="nobr"><a href="">Prototype</a></span>
library for performing asychronous Ajax messaging. All our <a href="/Web+Samples" title="Web
Samples">Ajax examples</a> are currently using OpenRico.</p>
+<div class="code"><div class="codeContent">
+<pre class="code-java">amq.sendMessage(myDestination,myMessage);</pre>
+<p>where <tt>myDestination</tt> is the URL string address of the destination
(e.g. "topic://MY.NAME"  or "channel://MY.NAME") and <tt>myMessage</tt> is any
well formed XML or plain text encoded as XML content.   </p>
-</div><div class="section_3"><h3><a name="Ajax-Serversideview"></a>Server
side view</h3>
+</div><div class="section_2"><h2><a name="Ajax-Receivingmessages."></a>Receiving
+<p>To receive messages, the client must define a message handling function and register
it with the <span class="nobr"><a href="">amq</a></span>
object. For example:</p>
+<div class="code"><div class="codeContent">
+<pre class="code-java"><span class="code-keyword">var</span> myHandler
+  rcvMessage: function(message) 
+  {
+     alert(<span class="code-quote">"received "</span>+message);
+  }
-<p>Here each HTTP GET or POST is just a regular use of the <a href="/REST" title="REST">REST</a>
API and so doesn't particularly care what the client is; whether its JavaScript or C or Ruby/Python
+<p>where <tt>myId</tt> is a string identifier that can be used for a later
call to <tt>amq.removeHandler(myId)</tt> and <tt>myDestination</tt>
is a URL string address of the destination (e.g. "topic://MY.NAME"  or "channel://MY.NAME").
 When a message is received, a call back to the <tt>myHandler.rcvMessage</tt>
function passes the message to your handling code.</p>
-<p>We use a MessageServlet on the server side to handle the HTTP traffic; together
with an optional NIO based servlet engine (Jetty) for handling large numbers of concurrent
-</div></div><div class="section_2"><h2><a name="Ajax-ReceivingMessages"></a>Receiving
+</div></div><div class="section_1"><h1><a name="Ajax-Howitworks"></a>How
it works</h1>
+<div class="section_2"><h2><a name="Ajax-MessageListenerServlet"></a>MessageListenerServlet</h2>
+<p>The ajax featues of amq are handled on the server side  by the <span class="nobr"><a
 This servlet is responsible for tracking the existing clients (using a HttpSesssion) and
lazily creating the AMQ and javax.jms objects required by the client to send and receive messages
(eg. Destination, MessageConsumer, MessageAVailableListener). This servlet should be mapped
to <tt>/amq/*</tt> in the web application context serving the Ajax client (this
can be changed, but the client javascript <tt>amq.uri</tt> field needs to be updated
to match.)</p>
+</div><div class="section_2"><h2><a name="Ajax-ClientSendingmessages"></a>Client
Sending messages</h2>
+<p>When a message is sent from the client it is encoded as the content of a POST request,
using the <span class="nobr"><a href="">prototype</a></span>
API for <span class="nobr"><a href="">XmlHttpRequest</a></span>.
 The <span class="nobr"><a href="">amq</a></span>
object may combine several sendMessage calls into a single POST if it can do so without adding
additional delays (see polling below). </p>
+<p>When the MessageListenerServlet receives a POST, the messages are decoded as <tt>application/x-www-form-urlencoded</tt>
parameters with their type (in this case <tt>send</tt> as opposed to <tt>listen</tt>
or <tt>unlisten</tt> see below) and destination.  If a destination channel or
topic do not exist, it is created. The message is sent to the destination as a TextMessage.</p>
+</div><div class="section_2"><h2><a name="Ajax-Listeningformessages"></a>Listening
for messages</h2>
+<p>When a client registers a listener, a message subscription request is sent from
the client to the server in a POST in the same way as a message, but with a type of <tt>listen</tt>.
 When the MessageListenerServlet receives a <tt>listen</tt> message, it lazily
creates a MessageAvailableConsumer and registers a Listener on it.</p>
+</div><div class="section_2"><h2><a name="Ajax-WaitingPollformessages"></a>Waiting
Poll for messages</h2>
+<p>When a Listener created by the MessageListenerServlet is called to indicate that
a message is available, due to the limitations of the HTTP client-server model, it is not
possible to send that message directly to the ajax client.   Instead the client must perform
a special type of <b>Poll</b> for messages.  Polling normally means periodically
making a request to see if there are messages available and there is a trade off: either the
poll frequency is high and excessive load is generated when the system is idle; or the frequency
is low and the latency for detecting new messages is high.  </p>
+<p>To avoid the load vs latency tradeoff, AMQ uses a waiting poll mechanism.  As soon
as the amq.js script is loaded, the client begins polling the server for available messages.
A poll request can be sent as a GET request or as a POST if there are other messages ready
to be delivered from the client to the server.  When the MessageListenerServlet receives a
poll it:</p>
+	<li>if the poll request is a POST, all <tt>send</tt>, <tt>listen</tt>
and <tt>unlisten</tt> messages are processed</li>
+	<li>if there are no messages available for the client on any of the subscribed channels
or topic, the servlet suspends the request handling until:
+	<ul>
+		<li>A MessageAvailableConsumer Listener is called to indicate that a message is now
available; or</li>
+		<li>A timeout expires (normally around 30 seconds, which is less than all common
TCP/IP, proxy and browser timeouts).</li>
+	</ul>
+	</li>
+	<li>A HTTP response is returned to the client containing all available messages encapsulated
as <tt>text/xml</tt>.</li>
+<p>When the amq.js javascipt receives the response to the poll, it processes all the
messages by passing them to the registered handler functions. Once it has processed all the
messages, it immediately sends another poll to the server.     </p>
+<p>Thus the idle state of the amq ajax feature is a poll request "parked" in the server,
waiting for messages to be sent to the client. Periodically this "parked" request is refreshed
by a timeout that prevents any TCP/IP, proxy or browser timeout closing the connection.  The
server is thus able to asynchronously send a message to the client by waking up the "parked"
request and allowing the response to be sent.  </p>
+<p>The client is able to asynchronously send a message to the server by creating  (or
using an existing) second connection to the server.  However, during the processing of the
poll response, normal client message sending is suspended, so that all messages to be sent
are queued and sent as a single POST with the poll that will be sent (with no delay) at the
end of the processing. This ensures that only two connections are required between client
and server (the normal for most browsers).</p>
+</div><div class="section_2"><h2><a name="Ajax-ThreadlessWaiting"></a>Threadless
+<p>The waiting poll described above is implemented using the <span class="nobr"><a
href="">Jetty 6 Continuation</a></span>
mechanism.  This allows the thread associated with the request to be released during the wait,
so that the container does not need to have a thread per client (which may be a large number).
  If another servlet container is used, the Continuation mechanism falls back to use a wait
and the thread is not released.</p>
-</div><div class="section_2"><h2><a name="Ajax-Sendingwhilereceiving"></a>Sending
while receiving</h2>
 </div></div><div class="section_1"><h1><a name="Ajax-ComparisontoPushlets"></a>Comparison
to Pushlets</h1>

Modified: incubator/activemq/site/OpenWire+dotNet
--- incubator/activemq/site/OpenWire+dotNet (original)
+++ incubator/activemq/site/OpenWire+dotNet Wed Mar  8 03:46:59 2006
@@ -268,10 +268,7 @@
 <p>You can browse the source code and tests <span class="nobr"><a href="">here</a></span><table
cellpadding="5" width="85%" cellspacing="8px" class="infoMacro" border="0" align="center"><colgroup><col
width="24"/><col/></colgroup><tr><td valign="top"><img src=""
width="16" height="16" align="absmiddle" alt="" border="0"/></td><td><b
class="strong">Using the right ActiveMQ version</b><br/><br/>
-Until ActiveMQ 4.0-M5 is out, you will need to use the <span class="nobr"><a href="">current
snapshot build</a></span> of ActiveMQ if you wish to use the OpenWire.Net client.</td></tr></table><br/>
+Until ActiveMQ 4.0-M5 is out, you will need to use the <span class="nobr"><a href="">current
snapshot build</a></span> of ActiveMQ if you wish to use the OpenWire.Net client.</td></tr></table></p>
 <div class="section_2"><h2><a name="OpenWiredotNet-Example"></a>Example</h2>
@@ -345,77 +342,13 @@
-</div><div class="section_2"><h2><a name="OpenWiredotNet-BuildingthecodeUsingNAnt"></a>Building
the code Using NAnt</h2>
+</div><div class="section_2"><h2><a name="OpenWiredotNet-Buildingthecode"></a>Building
the code</h2>
 <p>On Windows you can use Visual Studio to build the code. On Linux or OS X you can
use <span class="nobr"><a href="">Mono</a></span>.</p>
-<p>The build uses <span class="nobr"><a href="">NAnt</a></span>
which works on .Net and Mono.</p>
-<p>To build the code with Nant type the following</p>
-<div class="code"><div class="codeContent">
-<pre class="code-java">cd activemq-dotnet
-<p>&nbsp;<table cellpadding="5" width="85%" cellspacing="8px" class="warningMacro"
border="0" align="center"><colgroup><col width="24"/><col/></colgroup><tr><td
valign="top"><img src=""
width="16" height="16" align="absmiddle" alt="" border="0"/></td><td><b
class="strong">Running the Unit Tests</b><br/>
-<p>The unit tests depend on an ActiveMQ broker running on tcp://localhost:61616 so
that the test cases can connect to ActiveMQ and send and receive messages etc.<br/>
-So if you have a distribution of ActiveMQ, <a href="/Run+Broker" title="Run Broker">run
the broker</a> first before building OpenWire.Net</p></td></tr></table><br/>
-<p>If you want to run a build with the unit tests (assuming you have a broker running)
then type</p>
-<div class="code"><div class="codeContent">
-<pre class="code-java">nant test</pre>
-<div class="section_3"><h3><a name="OpenWiredotNet-SettingupNAntonMacOSX"></a>Setting
up NAnt on Mac OS X</h3>
-<p>To use NAnt on OS X</p>
-	<li>download the binary of <span class="nobr"><a href="">NAnt</a></span></li>
-	<li>create a script file called nant</li>
-	<li>chmod a+x nant</li>
-	<li>put the following into the script...</li>
-<div class="code"><div class="codeContent">
-<pre class="code-java">#!/bin/sh
-exec /usr/bin/mono /path/to/nant/NAnt.exe <span class="code-quote">"$@"</span></pre>
-<p>Thanks to the hints from <span class="nobr"><a href="">this
-</div></div><div class="section_2"><h2><a name="OpenWiredotNet-BuildingthecodeusingMaven2"></a>Building
the code using Maven 2</h2>
-<p>You can use the <span class="nobr"><a href="">Maven
C# plugin</a></span> to build the code if you have Maven 2.0.2 or later installed.</p>
-<p>Once that's done you only need to:</p>
-<div class="code"><div class="codeContent">
-<pre class="code-java">cd activemq-dotnet
-mvn install</pre>
-</div><div class="section_2"><h2><a name="OpenWiredotNet-%26nbsp%3BIDETips"></a>&nbsp;IDE
-<div class="section_3"><h3><a name="OpenWiredotNet-UsingXdevelop"></a>Using
<span class="nobr"><a href="">X-develop</a></span>
to edit C#</h3>
-<p>If you are on OS X we recommend the use of <span class="nobr"><a href="">X-develop</a></span>for
editing, refactoring and running the code.&nbsp; Just tell it to load the activemq-dotnet.sln
file and X-develop should be ready to go.</p>
-</div><div class="section_3"><h3><a name="OpenWiredotNet-UsingEclipsetoeditC%23"></a>Using
Eclipse to edit C#</h3>
-<p>You can use Eclipse as your IDE to edit C# code. If you are on Windows then we highly
recommend using <span class="nobr"><a href="">ReSharper</a></span>
- its a shame there is not a distro for OS X and Linux <img class="emoticon" src=""
height="20" width="20" align="absmiddle" alt="" border="0"/>.</p>
-<p>If you want to use Eclipse there are the following two C# eclipse plugins we are
aware of</p>
-	<li><span class="nobr"><a href="">BlackSun</a></span></li>
-	<li><span class="nobr"><a href="">Improve
+<p>The build can use <span class="nobr"><a href="">Maven</a></span>
or <span class="nobr"><a href="">NAnt</a></span>
which both work on .Net and Mono.</p>
-<p>We tend to use BlackSun as it has auto-format and outline view support along with
compiler warnings (though you might want to change the default font size).</p></div></div>
+<p>For more help see the <a href="/Building+CSharp+Code" title="Building CSharp
Code">Building CSharp Code</a> guide.</p></div>
 <div style="text-align: center; width: 100%; padding-top: 1cm;padding-bottom: 1cm">
 <script type="text/javascript"><!--

View raw message