Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 91457 invoked from network); 20 Feb 2007 18:59:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Feb 2007 18:59:24 -0000 Received: (qmail 41566 invoked by uid 500); 20 Feb 2007 18:59:32 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 41550 invoked by uid 500); 20 Feb 2007 18:59:32 -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 41537 invoked by uid 99); 20 Feb 2007 18:59:32 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Feb 2007 10:59:32 -0800 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Feb 2007 10:59:23 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 5585A1A981D; Tue, 20 Feb 2007 10:59:03 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r509706 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker: DestinationAlreadyExistsException.java region/AbstractRegion.java region/RegionBroker.java Date: Tue, 20 Feb 2007 18:59:03 -0000 To: commits@activemq.apache.org From: jstrachan@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070220185903.5585A1A981D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jstrachan Date: Tue Feb 20 10:59:02 2007 New Revision: 509706 URL: http://svn.apache.org/viewvc?view=rev&rev=509706 Log: Handle duplicate destinations & concurrency issues better Added: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/DestinationAlreadyExistsException.java (with props) Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java Added: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/DestinationAlreadyExistsException.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/DestinationAlreadyExistsException.java?view=auto&rev=509706 ============================================================================== --- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/DestinationAlreadyExistsException.java (added) +++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/DestinationAlreadyExistsException.java Tue Feb 20 10:59:02 2007 @@ -0,0 +1,40 @@ +/** + * + * 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.broker; + +import org.apache.activemq.command.ActiveMQDestination; + +import javax.jms.JMSException; + +/** + * An exception thrown if a destination is attempted to be created when it already exists. + * + * @version $Revision$ + */ +public class DestinationAlreadyExistsException extends JMSException { + private final ActiveMQDestination destination; + + public DestinationAlreadyExistsException(ActiveMQDestination destination) { + super("Destination already exists: " + destination); + this.destination = destination; + } + + public ActiveMQDestination getDestination() { + return destination; + } +} Propchange: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/DestinationAlreadyExistsException.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/DestinationAlreadyExistsException.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/DestinationAlreadyExistsException.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java?view=diff&rev=509706&r1=509705&r2=509706 ============================================================================== --- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java (original) +++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java Tue Feb 20 10:59:02 2007 @@ -25,6 +25,7 @@ import javax.jms.JMSException; import org.apache.activemq.broker.ConnectionContext; +import org.apache.activemq.broker.DestinationAlreadyExistsException; import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ConsumerInfo; import org.apache.activemq.command.Message; @@ -326,9 +327,15 @@ if(autoCreateDestinations){ // Try to auto create the destination... re-invoke broker from the // top so that the proper security checks are performed. - context.getBroker().addDestination(context,destination); + try { + dest = addDestination(context, destination); + //context.getBroker().addDestination(context,destination); + } + catch (DestinationAlreadyExistsException e) { + // if the destination already exists then lets ignore this error + } // We should now have the dest created. - dest=(Destination) destinations.get(destination); + //dest=(Destination) destinations.get(destination); } if(dest==null){ throw new JMSException("The destination "+destination+" does not exist."); Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java?view=diff&rev=509706&r1=509705&r2=509706 ============================================================================== --- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java (original) +++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java Tue Feb 20 10:59:02 2007 @@ -31,6 +31,7 @@ import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.Connection; import org.apache.activemq.broker.ConnectionContext; +import org.apache.activemq.broker.DestinationAlreadyExistsException; import org.apache.activemq.broker.region.policy.PendingDurableSubscriberMessageStoragePolicy; import org.apache.activemq.broker.region.policy.PolicyMap; import org.apache.activemq.broker.region.policy.VMPendingDurableSubscriberMessageStoragePolicy; @@ -244,7 +245,7 @@ public Destination addDestination(ConnectionContext context, ActiveMQDestination destination) throws Exception { if( destinations.contains(destination) ){ - throw new JMSException("Destination already exists: "+destination); + throw new DestinationAlreadyExistsException(destination); } Destination answer = null; switch(destination.getDestinationType()) {