Save This Page
Home » activemq-parent-5.3.1-source-release » org.apache » activemq » broker » region » [javadoc | source]
    1   /**
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.activemq.broker.region;
   18   
   19   import java.util.Iterator;
   20   import java.util.Set;
   21   
   22   import javax.jms.JMSException;
   23   
   24   import org.apache.activemq.broker.ConnectionContext;
   25   import org.apache.activemq.broker.region.policy.PolicyEntry;
   26   import org.apache.activemq.command.ActiveMQDestination;
   27   import org.apache.activemq.command.ConsumerInfo;
   28   import org.apache.activemq.command.MessageDispatchNotification;
   29   import org.apache.activemq.thread.TaskRunnerFactory;
   30   import org.apache.activemq.usage.SystemUsage;
   31   
   32   /**
   33    * 
   34    * @version $Revision: 1.9 $
   35    */
   36   public class QueueRegion extends AbstractRegion {
   37   
   38       public QueueRegion(RegionBroker broker, DestinationStatistics destinationStatistics,
   39                          SystemUsage memoryManager, TaskRunnerFactory taskRunnerFactory,
   40                          DestinationFactory destinationFactory) {
   41           super(broker, destinationStatistics, memoryManager, taskRunnerFactory, destinationFactory);
   42       }
   43   
   44       public String toString() {
   45           return "QueueRegion: destinations=" + destinations.size() + ", subscriptions=" + subscriptions.size()
   46                  + ", memory=" + usageManager.getMemoryUsage().getPercentUsage() + "%";
   47       }
   48   
   49       protected Subscription createSubscription(ConnectionContext context, ConsumerInfo info)
   50           throws JMSException {
   51           ActiveMQDestination destination = info.getDestination();
   52           PolicyEntry entry = null;
   53           if (destination != null && broker.getDestinationPolicy() != null) {
   54               entry = broker.getDestinationPolicy().getEntryFor(destination);
   55               
   56           }
   57           if (info.isBrowser()) {
   58               QueueBrowserSubscription sub = new QueueBrowserSubscription(broker,usageManager, context, info);
   59               if (entry != null) {
   60                   entry.configure(broker, usageManager, sub);
   61               }
   62               return sub;
   63           } else {
   64               QueueSubscription sub =   new QueueSubscription(broker, usageManager,context, info);
   65               if (entry != null) {
   66                   entry.configure(broker, usageManager, sub);
   67               }
   68               return sub;
   69           }
   70       }
   71   
   72       protected Set<ActiveMQDestination> getInactiveDestinations() {
   73           Set<ActiveMQDestination> inactiveDestinations = super.getInactiveDestinations();
   74           for (Iterator<ActiveMQDestination> iter = inactiveDestinations.iterator(); iter.hasNext();) {
   75               ActiveMQDestination dest = iter.next();
   76               if (!dest.isQueue()) {
   77                   iter.remove();
   78               }
   79           }
   80           return inactiveDestinations;
   81       }
   82       
   83       /*
   84        * For a Queue, dispatch order is imperative to match acks, so the dispatch is deferred till 
   85        * the notification to ensure that the subscription chosen by the master is used.
   86        * 
   87        * (non-Javadoc)
   88        * @see org.apache.activemq.broker.region.AbstractRegion#processDispatchNotification(org.apache.activemq.command.MessageDispatchNotification)
   89        */
   90       public void processDispatchNotification(MessageDispatchNotification messageDispatchNotification) throws Exception {
   91           processDispatchNotificationViaDestination(messageDispatchNotification);
   92       }
   93   }

Save This Page
Home » activemq-parent-5.3.1-source-release » org.apache » activemq » broker » region » [javadoc | source]