Save This Page
Home » activemq-parent-5.3.1-source-release » org.apache » activemq » broker » region » policy » [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.policy;
   18   
   19   import java.util.List;
   20   
   21   import org.apache.activemq.broker.region.MessageReference;
   22   import org.apache.activemq.broker.region.Subscription;
   23   import org.apache.activemq.filter.MessageEvaluationContext;
   24   
   25   /**
   26    * Abstraction to allow different dispatching policies to be plugged
   27    * into the region implementations.  This is used by a queue to deliver
   28    * messages to the matching subscriptions.
   29    * 
   30    * @version $Revision$
   31    */
   32   public interface DispatchPolicy {
   33       
   34       /**
   35        * Decides how to dispatch a selected message to a collection of consumers.  A safe
   36        * approach is to dispatch to every subscription that matches.  Queue Subscriptions that 
   37        * have not exceeded their pre-fetch limit will attempt to lock the message before 
   38        * dispatching to the client.  First subscription to lock the message wins.  
   39        * 
   40        * Order of dispatching to the subscriptions matters since a subscription with a 
   41        * large pre-fetch may take all the messages if he is always dispatched to first.  
   42        * Once a message has been locked, it does not need to be dispatched to any 
   43        * further subscriptions.
   44        * 
   45        * @return true if at least one consumer was dispatched or false if there are no active subscriptions that could be dispatched
   46        */
   47       boolean dispatch(MessageReference node, MessageEvaluationContext msgContext, List<Subscription> consumers) throws Exception;
   48   
   49   }

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