AMQQueue.java
001 /*
002  *
003  * Licensed to the Apache Software Foundation (ASF) under one
004  * or more contributor license agreements.  See the NOTICE file
005  * distributed with this work for additional information
006  * regarding copyright ownership.  The ASF licenses this file
007  * to you under the Apache License, Version 2.0 (the
008  * "License"); you may not use this file except in compliance
009  * with the License.  You may obtain a copy of the License at
010  *
011  *   http://www.apache.org/licenses/LICENSE-2.0
012  *
013  * Unless required by applicable law or agreed to in writing,
014  * software distributed under the License is distributed on an
015  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016  * KIND, either express or implied.  See the License for the
017  * specific language governing permissions and limitations
018  * under the License.
019  *
020  */
021 package org.apache.qpid.server.queue;
022 
023 import org.apache.qpid.server.management.Managable;
024 import org.apache.qpid.server.store.StoreContext;
025 import org.apache.qpid.server.configuration.QueueConfiguration;
026 import org.apache.qpid.server.configuration.ServerConfiguration;
027 import org.apache.qpid.server.exchange.Exchange;
028 import org.apache.qpid.server.virtualhost.VirtualHost;
029 import org.apache.qpid.server.subscription.Subscription;
030 import org.apache.qpid.framing.AMQShortString;
031 import org.apache.qpid.framing.FieldTable;
032 import org.apache.qpid.AMQException;
033 
034 import java.util.List;
035 import java.util.Set;
036 
037 public interface AMQQueue extends Managable, Comparable<AMQQueue>
038 {
039 
040     AMQShortString getName();
041 
042     boolean isDurable();
043 
044     boolean isAutoDelete();
045 
046     AMQShortString getOwner();
047 
048     VirtualHost getVirtualHost();
049 
050 
051     void bind(Exchange exchange, AMQShortString routingKey, FieldTable argumentsthrows AMQException;
052 
053     void unBind(Exchange exchange, AMQShortString routingKey, FieldTable argumentsthrows AMQException;
054 
055     List<ExchangeBinding> getExchangeBindings();
056 
057 
058     void registerSubscription(final Subscription subscription, final boolean exclusivethrows AMQException;
059 
060     void unregisterSubscription(final Subscription subscriptionthrows AMQException;
061 
062 
063     int getConsumerCount();
064 
065     int getActiveConsumerCount();
066 
067     boolean isUnused();
068 
069     boolean isEmpty();
070 
071     int getMessageCount();
072 
073     int getUndeliveredMessageCount();
074 
075 
076     long getQueueDepth();
077 
078     long getReceivedMessageCount();
079 
080     long getOldestMessageArrivalTime();
081 
082     boolean isDeleted();
083 
084     int delete() throws AMQException;
085 
086     QueueEntry enqueue(StoreContext storeContext, AMQMessage messagethrows AMQException;
087 
088     void requeue(StoreContext storeContext, QueueEntry entrythrows AMQException;
089 
090     void dequeue(StoreContext storeContext, QueueEntry entrythrows FailedDequeueException;
091 
092     boolean resend(final QueueEntry entry, final Subscription subscriptionthrows AMQException;
093 
094     void addQueueDeleteTask(final Task task);
095 
096     List<QueueEntry> getMessagesOnTheQueue();
097 
098     List<QueueEntry> getMessagesOnTheQueue(long fromMessageId, long toMessageId);
099 
100     List<Long> getMessagesOnTheQueue(int num);
101 
102     List<Long> getMessagesOnTheQueue(int num, int offest);
103 
104     QueueEntry getMessageOnTheQueue(long messageId);
105 
106 
107     void moveMessagesToAnotherQueue(long fromMessageId, long toMessageId, String queueName,
108                                                         StoreContext storeContext);
109 
110     void copyMessagesToAnotherQueue(long fromMessageId, long toMessageId, String queueName, StoreContext storeContext);
111 
112     void removeMessagesFromQueue(long fromMessageId, long toMessageId, StoreContext storeContext);
113 
114 
115 
116     long getMaximumMessageSize();
117 
118     void setMaximumMessageSize(long value);
119 
120 
121     long getMaximumMessageCount();
122 
123     void setMaximumMessageCount(long value);
124 
125 
126     long getMaximumQueueDepth();
127 
128     void setMaximumQueueDepth(long value);
129 
130 
131     long getMaximumMessageAge();
132 
133     void setMaximumMessageAge(final long maximumMessageAge);
134 
135 
136     long getMinimumAlertRepeatGap();
137 
138     void setMinimumAlertRepeatGap(long value);
139 
140 
141     void deleteMessageFromTop(StoreContext storeContextthrows AMQException;
142 
143     long clearQueue(StoreContext storeContextthrows AMQException;
144 
145     /**
146      * Checks the status of messages on the queue, purging expired ones, firing age related alerts etc.
147      @throws AMQException
148      */
149     void checkMessageStatus() throws AMQException;
150 
151     Set<NotificationCheck> getNotificationChecks();
152 
153     void flushSubscription(final Subscription subthrows AMQException;
154 
155     void deliverAsync(final Subscription sub);
156 
157     void deliverAsync();
158 
159     void stop();
160 
161     /**
162      * ExistingExclusiveSubscription signals a failure to create a subscription, because an exclusive subscription
163      * already exists.
164      *
165      <p/><table id="crc"><caption>CRC Card</caption>
166      <tr><th> Responsibilities <th> Collaborations
167      <tr><td> Represent failure to create a subscription, because an exclusive subscription already exists.
168      </table>
169      *
170      * @todo Not an AMQP exception as no status code.
171      *
172      * @todo Move to top level, used outside this class.
173      */
174     static final class ExistingExclusiveSubscription extends AMQException
175     {
176 
177         public ExistingExclusiveSubscription()
178         {
179             super("");
180         }
181     }
182 
183     /**
184      * ExistingSubscriptionPreventsExclusive signals a failure to create an exclusize subscription, as a subscription
185      * already exists.
186      *
187      <p/><table id="crc"><caption>CRC Card</caption>
188      <tr><th> Responsibilities <th> Collaborations
189      <tr><td> Represent failure to create an exclusize subscription, as a subscription already exists.
190      </table>
191      *
192      * @todo Not an AMQP exception as no status code.
193      *
194      * @todo Move to top level, used outside this class.
195      */
196     static final class ExistingSubscriptionPreventsExclusive extends AMQException
197     {
198         public ExistingSubscriptionPreventsExclusive()
199         {
200             super("");
201         }
202     }
203 
204     static interface Task
205     {
206         public void doTask(AMQQueue queuethrows AMQException;
207     }
208 }