KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > broker > region > policy > DispatchPolicy


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.broker.region.policy;
19
20 import java.util.List JavaDoc;
21
22 import org.apache.activemq.broker.ConnectionContext;
23 import org.apache.activemq.broker.region.MessageReference;
24 import org.apache.activemq.filter.MessageEvaluationContext;
25
26 /**
27  * Abstraction to allow different dispatching policies to be plugged
28  * into the region implementations. This is used by a queue to deliver
29  * messages to the matching subscriptions.
30  *
31  * @version $Revision$
32  */

33 public interface DispatchPolicy {
34     
35     /**
36      * Decides how to dispatch a selected message to a collection of consumers. A safe
37      * approach is to dispatch to every subscription that matches. Queue Subscriptions that
38      * have not exceeded their pre-fetch limit will attempt to lock the message before
39      * dispatching to the client. First subscription to lock the message wins.
40      *
41      * Order of dispatching to the subscriptions matters since a subscription with a
42      * large pre-fetch may take all the messages if he is always dispatched to first.
43      * Once a message has been locked, it does not need to be dispatched to any
44      * further subscriptions.
45      *
46      * @return true if at least one consumer was dispatched or false if there are no active subscriptions that could be dispatched
47      */

48     boolean dispatch(MessageReference node, MessageEvaluationContext msgContext, List JavaDoc consumers) throws Exception JavaDoc;
49
50 }
51
Popular Tags