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.io.IOException;
   20   import java.util.List;
   21   
   22   import javax.jms.InvalidSelectorException;
   23   import javax.management.ObjectName;
   24   
   25   import org.apache.activemq.broker.ConnectionContext;
   26   import org.apache.activemq.command.ActiveMQDestination;
   27   import org.apache.activemq.command.ConsumerInfo;
   28   import org.apache.activemq.command.MessageAck;
   29   import org.apache.activemq.command.MessageDispatchNotification;
   30   import org.apache.activemq.command.MessagePull;
   31   import org.apache.activemq.command.Response;
   32   import org.apache.activemq.filter.MessageEvaluationContext;
   33   
   34   /**
   35    * @version $Revision: 1.5 $
   36    */
   37   public interface Subscription extends SubscriptionRecovery {
   38   
   39       /**
   40        * Used to add messages that match the subscription.
   41        * @param node
   42        * @throws Exception 
   43        * @throws InterruptedException 
   44        * @throws IOException 
   45        */
   46       void add(MessageReference node) throws Exception;
   47       
   48       /**
   49        * Used when client acknowledge receipt of dispatched message. 
   50        * @param node
   51        * @throws IOException 
   52        * @throws Exception 
   53        */
   54       void acknowledge(ConnectionContext context, final MessageAck ack) throws Exception;
   55       
   56   
   57       /**
   58        * Allows a consumer to pull a message on demand
   59        */
   60       Response pullMessage(ConnectionContext context, MessagePull pull) throws Exception;
   61   
   62       /**
   63        * Is the subscription interested in the message?
   64        * @param node 
   65        * @param context
   66        * @return
   67        * @throws IOException 
   68        */
   69       boolean matches(MessageReference node, MessageEvaluationContext context) throws IOException;
   70       
   71       /**
   72        * Is the subscription interested in messages in the destination?
   73        * @param context
   74        * @return
   75        */
   76       boolean matches(ActiveMQDestination destination);
   77       
   78       /**
   79        * The subscription will be receiving messages from the destination.
   80        * @param context 
   81        * @param destination
   82        * @throws Exception 
   83        */
   84       void add(ConnectionContext context, Destination destination) throws Exception;
   85       
   86       /**
   87        * The subscription will be no longer be receiving messages from the destination.
   88        * @param context 
   89        * @param destination
   90        * @return a list of un-acked messages that were added to the subscription.
   91        */
   92       List<MessageReference> remove(ConnectionContext context, Destination destination) throws Exception;
   93       
   94       /**
   95        * The ConsumerInfo object that created the subscription.
   96        * @param destination
   97        */
   98       ConsumerInfo getConsumerInfo();
   99   
  100       /**
  101        * The subscription should release as may references as it can to help the garbage collector
  102        * reclaim memory.
  103        */
  104       void gc();
  105       
  106       /**
  107        * Used by a Slave Broker to update dispatch infomation
  108        * @param mdn
  109        * @throws Exception 
  110        */
  111       void processMessageDispatchNotification(MessageDispatchNotification  mdn) throws Exception;
  112       
  113       /**
  114        * @return true if the broker is currently in slave mode
  115        */
  116       boolean isSlave();
  117       
  118       /**
  119        * @return number of messages pending delivery
  120        */
  121       int getPendingQueueSize();
  122       
  123       /**
  124        * @return number of messages dispatched to the client
  125        */
  126       int getDispatchedQueueSize();
  127           
  128       /**
  129        * @return number of messages dispatched to the client
  130        */
  131       long getDispatchedCounter();
  132       
  133       /**
  134        * @return number of messages that matched the subscription
  135        */
  136       long getEnqueueCounter();
  137   
  138       /**
  139        * @return number of messages queued by the client
  140        */
  141       long getDequeueCounter();
  142   
  143       /**
  144        * @return the JMS selector on the current subscription
  145        */
  146       String getSelector();
  147       
  148       /**
  149        * Attempts to change the current active selector on the subscription.
  150        * This operation is not supported for persistent topics.
  151        */
  152       void setSelector(String selector) throws InvalidSelectorException, UnsupportedOperationException;
  153   
  154       /**
  155        * @return the JMX object name that this subscription was registered as if applicable
  156        */
  157       ObjectName getObjectName();
  158   
  159       /**
  160        * Set when the subscription is registered in JMX
  161        */
  162       void setObjectName(ObjectName objectName);
  163       
  164       /**
  165        * @return true when 60% or more room is left for dispatching messages
  166        */
  167       boolean isLowWaterMark();
  168       
  169       /**
  170        * @return true when 10% or less room is left for dispatching messages
  171        */
  172       boolean isHighWaterMark();
  173       
  174       /**
  175        * @return true if there is no space to dispatch messages
  176        */
  177       boolean isFull();
  178       
  179       /**
  180        * inform the MessageConsumer on the client to change it's prefetch
  181        * @param newPrefetch
  182        */
  183       void updateConsumerPrefetch(int newPrefetch);
  184       
  185           
  186       /**
  187        * Called when the subscription is destroyed.
  188        */
  189       void destroy();
  190   
  191       /**
  192        * @return the prefetch size that is configured for the subscription
  193        */
  194       int getPrefetchSize();
  195       
  196       /**
  197        * @return the number of messages awaiting acknowledgement
  198        */
  199       int getInFlightSize();
  200       
  201       /**
  202        * @return the in flight messages as a percentage of the prefetch size
  203        */
  204       int getInFlightUsage();
  205       
  206       /**
  207        * Informs the Broker if the subscription needs to intervention to recover it's state
  208        * e.g. DurableTopicSubscriber may do
  209        * @see org.apache.activemq.region.cursors.PendingMessageCursor
  210        * @return true if recovery required
  211        */
  212       boolean isRecoveryRequired();
  213       
  214       
  215       /**
  216        * @return true if a browser
  217        */
  218       boolean isBrowser();
  219       
  220       /**
  221        * @return the number of messages this subscription can accept before its full
  222        */
  223       int countBeforeFull();
  224   
  225       ConnectionContext getContext();
  226       
  227       public int getCursorMemoryHighWaterMark();
  228   
  229   	public void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark);
  230   }

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