Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8E9E048EC for ; Wed, 11 May 2011 18:44:05 +0000 (UTC) Received: (qmail 33119 invoked by uid 500); 11 May 2011 18:44:05 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 33090 invoked by uid 500); 11 May 2011 18:44:05 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 33083 invoked by uid 99); 11 May 2011 18:44:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 May 2011 18:44:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 May 2011 18:44:04 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 1E0782388980; Wed, 11 May 2011 18:43:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1102014 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/store/kahadb/KahaDBStore.java test/java/org/apache/activemq/store/kahadb/KahaDBStoreTest.java Date: Wed, 11 May 2011 18:43:44 -0000 To: commits@activemq.apache.org From: gtully@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110511184344.1E0782388980@eris.apache.org> Author: gtully Date: Wed May 11 18:43:43 2011 New Revision: 1102014 URL: http://svn.apache.org/viewvc?rev=1102014&view=rev Log: https://issues.apache.org/jira/browse/AMQ-3272 - Handle RejectedExecutionException. In this case avoid the root cause, by allowing the semaphore to limit the enqueue tasks. Issue was in the cancel case locks were being release and the semaphore dropped while the executore queue still had the task pending, it needs to execute before the the samaphore can be released as it gates the task queue Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreTest.java (with props) Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java?rev=1102014&r1=1102013&r2=1102014&view=diff ============================================================================== --- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java (original) +++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java Wed May 11 18:43:43 2011 @@ -1067,7 +1067,6 @@ public class KahaDBStore extends Message } public boolean cancel() { - releaseLocks(); if (this.done.compareAndSet(false, true)) { return this.future.cancel(false); } Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreTest.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreTest.java?rev=1102014&view=auto ============================================================================== --- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreTest.java (added) +++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreTest.java Wed May 11 18:43:43 2011 @@ -0,0 +1,109 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.store.kahadb; + +import java.util.Vector; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import org.apache.activemq.command.ActiveMQDestination; +import org.apache.activemq.command.ActiveMQMessage; +import org.apache.activemq.command.ActiveMQQueue; +import org.apache.activemq.command.Message; +import org.apache.activemq.command.MessageAck; +import org.apache.activemq.command.MessageId; +import org.apache.activemq.command.ProducerId; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +import static org.junit.Assert.assertTrue; + +public class KahaDBStoreTest { + + KahaDBStore.KahaDBMessageStore underTest; + KahaDBStore store; + ActiveMQMessage message; + ProducerId producerId = new ProducerId("1.1.1"); + private static final int MESSAGE_COUNT = 2000; + private Vector exceptions = new Vector(); + + @Before + public void initStore() throws Exception { + ActiveMQDestination destination = new ActiveMQQueue("Test"); + store = new KahaDBStore(); + store.setMaxAsyncJobs(100); + store.setDeleteAllMessages(true); + store.start(); + underTest = store.new KahaDBMessageStore(destination); + underTest.start(); + message = new ActiveMQMessage(); + message.setDestination(destination); + } + + @After + public void destroyStore() throws Exception { + if (store != null) { + store.stop(); + } + } + + @Test + public void testConcurrentStoreAndDispatchQueue() throws Exception { + + ExecutorService executor = Executors.newCachedThreadPool(); + for (int i=0; i