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
This commit is contained in:
Robert Davies 2007-03-07 06:01:00 +00:00
parent 05de2b1f47
commit d00ce72595
1 changed files with 14 additions and 22 deletions

View File

@ -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);
}
}
}