01 /*
02 *
03 * Licensed to the Apache Software Foundation (ASF) under one
04 * or more contributor license agreements. See the NOTICE file
05 * distributed with this work for additional information
06 * regarding copyright ownership. The ASF licenses this file
07 * to you under the Apache License, Version 2.0 (the
08 * "License"); you may not use this file except in compliance
09 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 */
21 package org.apache.qpid.server.queue;
22
23 import org.apache.qpid.framing.AMQShortString;
24 import org.apache.qpid.server.virtualhost.VirtualHost;
25 import org.apache.qpid.server.subscription.SubscriptionList;
26 import org.apache.qpid.server.subscription.Subscription;
27 import org.apache.qpid.AMQException;
28
29 public class AMQPriorityQueue extends SimpleAMQQueue
30 {
31 protected AMQPriorityQueue(final AMQShortString name,
32 final boolean durable,
33 final AMQShortString owner,
34 final boolean autoDelete,
35 final VirtualHost virtualHost,
36 int priorities)
37 throws AMQException
38 {
39 super(name, durable, owner, autoDelete, virtualHost, new PriorityQueueList.Factory(priorities));
40 }
41
42 public int getPriorities()
43 {
44 return ((PriorityQueueList) _entries).getPriorities();
45 }
46
47 @Override
48 protected void checkSubscriptionsNotAheadOfDelivery(final QueueEntry entry)
49 {
50 // check that all subscriptions are not in advance of the entry
51 SubscriptionList.SubscriptionNodeIterator subIter = _subscriptionList.iterator();
52 while(subIter.advance() && !entry.isAcquired())
53 {
54 final Subscription subscription = subIter.getNode().getSubscription();
55 QueueEntry subnode = subscription.getLastSeenEntry();
56 while(subnode != null && entry.compareTo(subnode) < 0 && !entry.isAcquired())
57 {
58 if(subscription.setLastSeenEntry(subnode,entry))
59 {
60 break;
61 }
62 else
63 {
64 subnode = subscription.getLastSeenEntry();
65 }
66 }
67
68 }
69 }
70
71 }
|