Return-Path: Delivered-To: apmail-geronimo-activemq-commits-archive@www.apache.org Received: (qmail 31104 invoked from network); 9 Mar 2006 03:59:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 9 Mar 2006 03:59:27 -0000 Received: (qmail 8166 invoked by uid 500); 9 Mar 2006 03:59:27 -0000 Delivered-To: apmail-geronimo-activemq-commits-archive@geronimo.apache.org Received: (qmail 8141 invoked by uid 500); 9 Mar 2006 03:59:27 -0000 Mailing-List: contact activemq-commits-help@geronimo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: activemq-dev@geronimo.apache.org Delivered-To: mailing list activemq-commits@geronimo.apache.org Received: (qmail 8130 invoked by uid 99); 9 Mar 2006 03:59:26 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Mar 2006 19:59:26 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 08 Mar 2006 19:59:26 -0800 Received: (qmail 30972 invoked by uid 65534); 9 Mar 2006 03:59:06 -0000 Message-ID: <20060309035906.30971.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r384419 - /incubator/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/BlockingQueueTransport.java Date: Thu, 09 Mar 2006 03:59:05 -0000 To: activemq-commits@geronimo.apache.org From: aco@apache.org X-Mailer: svnmailer-1.0.7 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: aco Date: Wed Mar 8 19:59:03 2006 New Revision: 384419 URL: http://svn.apache.org/viewcvs?rev=384419&view=rev Log: Use offer to wait (with timeout of 30secs) for space in case the queue is full. Modified: incubator/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/BlockingQueueTransport.java Modified: incubator/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/BlockingQueueTransport.java URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/BlockingQueueTransport.java?rev=384419&r1=384418&r2=384419&view=diff ============================================================================== --- incubator/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/BlockingQueueTransport.java (original) +++ incubator/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/BlockingQueueTransport.java Wed Mar 8 19:59:03 2006 @@ -18,6 +18,7 @@ import edu.emory.mathcs.backport.java.util.Queue; import edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue; +import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit; import org.apache.activemq.command.Command; import org.apache.activemq.transport.TransportSupport; @@ -35,6 +36,8 @@ * @version $Revision$ */ public class BlockingQueueTransport extends TransportSupport { + public static final long MAX_TIMEOUT = 30000L; + private BlockingQueue queue; public BlockingQueueTransport(BlockingQueue channel) { @@ -46,7 +49,13 @@ } public void oneway(Command command) throws IOException { - queue.add(command); + try { + boolean success = queue.offer(command, MAX_TIMEOUT, TimeUnit.MILLISECONDS); + if (!success) + throw new IOException("Fail to add to BlockingQueue. Add timed out after " + MAX_TIMEOUT + "ms: size=" + queue.size()); + } catch (InterruptedException e) { + throw new IOException("Fail to add to BlockingQueue. Interrupted while waiting for space: size=" + queue.size()); + } } protected void doStart() throws Exception {