KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.apache.activemq.command.ActiveMQDestination;
21 import org.apache.activemq.command.Message;
22
23 import javax.jms.MessageListener JavaDoc;
24
25 /**
26  * Represents some kind of query which will load initial messages from some source for a new topic subscriber.
27  *
28  * @version $Revision: 426366 $
29  */

30 public interface MessageQuery {
31     
32     /**
33      * Executes the query for messages; each message is passed into the listener
34      *
35      * @param destination the destination on which the query is to be performed
36      * @param listener is the listener to notify as each message is created or loaded
37      */

38     public void execute(ActiveMQDestination destination, MessageListener JavaDoc listener) throws Exception JavaDoc;
39
40     /**
41      * Returns true if the given update is valid and does not overlap with the initial message query.
42      * When performing an initial load from some source, there is a chance that an update may occur which is logically before
43      * the message sent on the initial load - so this method provides a hook where the query instance can keep track of the version IDs
44      * of the messages sent so that if an older version is sent as an update it can be excluded to avoid going backwards in time.
45      *
46      * e.g. if the execute() method creates version 2 of an object and then an update message is sent for version 1, this method should return false to
47      * hide the old update message.
48      *
49      * @param message the update message which may have been sent before the query actually completed
50      * @return true if the update message is valid otherwise false in which case the update message will be discarded.
51      */

52     public boolean validateUpdate(Message message);
53
54 }
55
Popular Tags