From f25d9269afd0b608319b0a26e63f38d756fc2b61 Mon Sep 17 00:00:00 2001 From: Gregory John Wilkins Date: Wed, 26 Apr 2006 10:16:45 +0000 Subject: [PATCH] batch support git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@397165 13f79535-47bb-0310-9956-ffa450edef68 --- .../resources/org/apache/activemq/web/_amq.js | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/activemq-web/src/main/resources/org/apache/activemq/web/_amq.js b/activemq-web/src/main/resources/org/apache/activemq/web/_amq.js index 03c330df36..65331e35e9 100644 --- a/activemq-web/src/main/resources/org/apache/activemq/web/_amq.js +++ b/activemq-web/src/main/resources/org/apache/activemq/web/_amq.js @@ -19,7 +19,7 @@ var amq = _messages:0, _messageQueue: '', - _queueMessages: false, + _queueMessages: 0, _messageHandler: function(request) { @@ -51,7 +51,7 @@ var amq = { handler(child); } - } + } } } } @@ -63,9 +63,26 @@ var amq = } }, + 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 @@ var amq = 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 @@ var amq = _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 @@ function getKeyCode(ev) else keyc=ev.keyCode; return keyc; -} \ No newline at end of file +}