activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
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 GMT
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()) {



Mime
View raw message