From d00ce72595a14b9f46e29f26bec22578e6445faa Mon Sep 17 00:00:00 2001 From: Robert Davies Date: Wed, 7 Mar 2007 06:01:00 +0000 Subject: [PATCH] not a problem to try and create a destination more than once git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@515466 13f79535-47bb-0310-9956-ffa450edef68 --- .../broker/region/AbstractRegion.java | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java b/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java index 8241a3348a..fbc231b6d8 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java @@ -97,33 +97,25 @@ abstract public class AbstractRegion implements Region { destinations.clear(); } - public Destination addDestination(ConnectionContext context, ActiveMQDestination destination) throws Exception { + public Destination addDestination(ConnectionContext context,ActiveMQDestination destination) throws Exception{ log.debug("Adding destination: "+destination); - - synchronized (destinationsMutex) { - Destination dest = (Destination) destinations.get(destination); - if (dest != null) { - log.warn("Attempt to add destination which is already created: " + destination); - } - else { - dest = createDestination(context, destination); - + synchronized(destinationsMutex){ + Destination dest=(Destination)destinations.get(destination); + if(dest==null){ + dest=createDestination(context,destination); // intercept if there is a valid interceptor defined - DestinationInterceptor destinationInterceptor = broker.getDestinationInterceptor(); - if (destinationInterceptor != null) { - dest = destinationInterceptor.intercept(dest); + DestinationInterceptor destinationInterceptor=broker.getDestinationInterceptor(); + if(destinationInterceptor!=null){ + dest=destinationInterceptor.intercept(dest); } - dest.start(); - - destinations.put(destination, dest); - destinationMap.put(destination, dest); - + destinations.put(destination,dest); + destinationMap.put(destination,dest); // Add all consumers that are interested in the destination. - for (Iterator iter = subscriptions.values().iterator(); iter.hasNext();) { - Subscription sub = (Subscription) iter.next(); - if (sub.matches(destination)) { - dest.addSubscription(context, sub); + for(Iterator iter=subscriptions.values().iterator();iter.hasNext();){ + Subscription sub=(Subscription)iter.next(); + if(sub.matches(destination)){ + dest.addSubscription(context,sub); } } }