activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gr...@apache.org
Subject svn commit: r397165 - /incubator/activemq/trunk/activemq-web/src/main/resources/org/apache/activemq/web/_amq.js
Date Wed, 26 Apr 2006 10:16:53 GMT
Author: gregw
Date: Wed Apr 26 03:16:45 2006
New Revision: 397165

URL: http://svn.apache.org/viewcvs?rev=397165&view=rev
Log:
batch support

Modified:
    incubator/activemq/trunk/activemq-web/src/main/resources/org/apache/activemq/web/_amq.js

Modified: incubator/activemq/trunk/activemq-web/src/main/resources/org/apache/activemq/web/_amq.js
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-web/src/main/resources/org/apache/activemq/web/_amq.js?rev=397165&r1=397164&r2=397165&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-web/src/main/resources/org/apache/activemq/web/_amq.js
(original)
+++ incubator/activemq/trunk/activemq-web/src/main/resources/org/apache/activemq/web/_amq.js
Wed Apr 26 03:16:45 2006
@@ -19,7 +19,7 @@
 
   _messages:0,
   _messageQueue: '',
-  _queueMessages: false,
+  _queueMessages: 0,
 
   _messageHandler: function(request)
   {
@@ -51,7 +51,7 @@
                 {
                   handler(child);
                 }
-                      }
+	      }
             }
           }
         }
@@ -63,9 +63,26 @@
     }
   },
 
+  startBatch: function()
+  {
+    amq._queueMessages++;
+  },
+
+  endBatch: function()
+  {
+    amq._queueMessages--;
+    if (amq._queueMessages==0 && amq._messages>0)
+    {
+      var body = amq._messageQueue;
+      amq._messageQueue='';
+      amq._messages=0;
+      new Ajax.Request(amq.uri, { method: 'post', postBody: body});
+    }
+  },
+
   _pollHandler: function(request)
   {
-    amq._queueMessages=true;
+    amq._queueMessages++;
     try
     {
       amq._messageHandler(request);
@@ -77,20 +94,19 @@
         alert(e);
     }
 
-    amq._queueMessages=false;
+    amq._queueMessages--;
 
-    if (amq._messages==0)
-    {
-      if (amq.poll)
-        new Ajax.Request(amq.uri, { method: 'get', onSuccess: amq._pollHandler });
-    }
-    else
+    if (amq._queueMessages==0 && amq._messages>0)
     {
       var body = amq._messageQueue+'&poll='+amq.poll;
       amq._messageQueue='';
       amq._messages=0;
       new Ajax.Request(amq.uri, { method: 'post', onSuccess: amq._pollHandler, postBody:
body });
     }
+    else if (amq.poll)
+    {
+        new Ajax.Request(amq.uri, { method: 'get', onSuccess: amq._pollHandler });
+    }
   },
 
   // Add a function that gets called on every poll response, after all received
@@ -129,7 +145,7 @@
 
   _sendMessage : function(destination,message,type)
   {
-    if (amq._queueMessages)
+    if (amq._queueMessages>0)
     {
       amq._messageQueue+=(amq._messages==0?'destination=':'&destination=')+destination+'&message='+message+'&type='+type;
       amq._messages++;
@@ -157,4 +173,4 @@
     else
         keyc=ev.keyCode;
     return keyc;
-}
\ No newline at end of file
+}



Mime
View raw message