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 javax.jms.MessageListener;
   20   
   21   import org.apache.activemq.command.ActiveMQDestination;
   22   import org.apache.activemq.command.Message;
   23   
   24   /**
   25    * Represents some kind of query which will load initial messages from some source for a new topic subscriber.
   26    * 
   27    * @version $Revision: 564271 $
   28    */
   29   public interface MessageQuery {
   30       
   31       /**
   32        * Executes the query for messages; each message is passed into the listener
   33        * 
   34        * @param destination the destination on which the query is to be performed
   35        * @param listener is the listener to notify as each message is created or loaded
   36        */
   37       void execute(ActiveMQDestination destination, MessageListener listener) throws Exception;
   38   
   39       /**
   40        * Returns true if the given update is valid and does not overlap with the initial message query.
   41        * When performing an initial load from some source, there is a chance that an update may occur which is logically before
   42        * the message sent on the initial load - so this method provides a hook where the query instance can keep track of the version IDs
   43        * 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.
   44        * 
   45        * 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 
   46        * hide the old update message.
   47        * 
   48        * @param message the update message which may have been sent before the query actually completed
   49        * @return true if the update message is valid otherwise false in which case the update message will be discarded.
   50        */
   51       boolean validateUpdate(Message message);
   52   
   53   }

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