Package org.apache.qpid.server.subscription

Examples of org.apache.qpid.server.subscription.Subscription


    {
        if(_messageGroupManager == null || !sub.acquires())
        {
            return true;
        }
        Subscription assigned = _messageGroupManager.getAssignedSubscription(entry);
        return (assigned == null) || (assigned == sub);
    }
View Full Code Here


    {
        SubscriptionList.SubscriptionNodeIterator subscriberIter = _subscriptionList.iterator();
        // iterate over all the subscribers, and if they are in advance of this queue entry then move them backwards
        while (subscriberIter.advance() && entry.isAvailable())
        {
            Subscription sub = subscriberIter.getNode().getSubscription();

            // we don't make browsers send the same stuff twice
            if (sub.seesRequeues())
            {
                updateSubRequeueEntry(sub, entry);
            }
        }
View Full Code Here

            SubscriptionList.SubscriptionNodeIterator subscriptionIter = _subscriptionList.iterator();

            while (subscriptionIter.advance())
            {
                Subscription s = subscriptionIter.getNode().getSubscription();
                if (s != null)
                {
                    s.queueDeleted(this);
                }
            }

            _virtualHost.getQueueRegistry().unregisterQueue(_name);
View Full Code Here

    {
        SubscriptionList.SubscriptionNodeIterator subscriberIter = _subscriptionList.iterator();
        while (subscriberIter.advance())
        {
            SubscriptionList.SubscriptionNode subNode = subscriberIter.getNode();
            Subscription sub = subNode.getSubscription();
            if(sub.acquires())
            {
                getNextAvailableEntry(sub);
            }
            else
            {
View Full Code Here

            SubscriptionList.SubscriptionNodeIterator subscriptionIter = _subscriptionList.iterator();
            //iterate over the subscribers and try to advance their pointer
            while (subscriptionIter.advance())
            {
                Subscription sub = subscriptionIter.getNode().getSubscription();
                sub.getSendLock();

                    try
                    {
                        for(int i = 0 ; i < perSub; i++)
                        {
                            //attempt delivery. returns true if no further delivery currently possible to this sub
                            subscriptionDone = attemptDelivery(sub, true);
                            if (subscriptionDone)
                            {
                                sub.flushBatched();
                                if (lastLoop && !sub.isSuspended())
                                {
                                    sub.queueEmpty();
                                }
                                break;
                            }
                            else
                            {
                                //this subscription can accept additional deliveries, so we must
                                //keep going after this (if iteration slicing allows it)
                                allSubscriptionsDone = false;
                                lastLoop = false;
                                if(--iterations == 0)
                                {
                                    sub.flushBatched();
                                    break;
                                }
                            }

                        }

                        sub.flushBatched();
                    }
                    finally
                    {
                        sub.releaseSendLock();
                    }
            }

            if(allSubscriptionsDone && lastLoop)
            {
View Full Code Here

        object.put("state",entry.isAvailable()
                                   ? "Available"
                                   : entry.isAcquired()
                                             ? "Acquired"
                                             : "");
        final Subscription deliveredSubscription = entry.getDeliveredSubscription();
        object.put("deliveredTo", deliveredSubscription == null ? null : deliveredSubscription.getSubscriptionID());
        ServerMessage message = entry.getMessage();

        if(message != null)
        {
            convertMessageProperties(object, message);
View Full Code Here

    {
        // check that all subscriptions are not in advance of the entry
        Iterator<Subscription> subIter = _subscriptionList.iterator();
        while(subIter.hasNext() && !entry.isAcquired())
        {
            final Subscription subscription = subIter.next();
            if(!subscription.isClosed())
            {
                QueueContext context = (QueueContext) subscription.getQueueContext();
                if(context != null)
                {
                    QueueEntry subnode = context._lastSeenEntry;
                    QueueEntry released = context._releasedEntry;
                    while(subnode != null && entry.compareTo(subnode) < 0 && !entry.isAcquired() && (released == null || released.compareTo(entry) < 0))
View Full Code Here

        incrementQueueSize(message);
        _totalMessagesReceived.incrementAndGet();


        QueueEntry entry;
        Subscription exclusiveSub = _exclusiveSubscriber;

        if (exclusiveSub != null)
        {
            exclusiveSub.getSendLock();

            try
            {
                entry = _entries.add(message);

                deliverToSubscription(exclusiveSub, entry);
            }
            finally
            {
                exclusiveSub.releaseSendLock();
            }
        }
        else
        {
            entry = _entries.add(message);
            /*

            iterate over subscriptions and if any is at the end of the queue and can deliver this message, then deliver the message

             */
            Subscription nextNode = null;
           
           
           
           
            boolean refTransferDone = false;
           
            while(!refTransferDone){
                Subscription node = _lastSubscriptionNode.get();
                nextNode = findNextNode(node);
                if(_lastSubscriptionNode.compareAndSet(node, nextNode)){
                  refTransferDone = true;
                }
            }

           

            // always do one extra loop after we believe we've finished
            // this catches the case where we *just* miss an update
            int loops = 2;

            while (!(entry.isAcquired() || entry.isDeleted()) && loops != 0)
            {
                if (nextNode == null)
                {
                    loops--;
                    nextNode = _subscriptionList.getHead();
                }
                else
                {
                    // if subscription at end, and active, offer
                    Subscription sub = nextNode;
                    deliverToSubscription(sub, entry);
                }
                nextNode = findNextNode(nextNode);

            }
View Full Code Here

    private Subscription findNextNode(Subscription node){
      if(node == null){
        return null;
      }
      Iterator<Subscription> it = _subscriptionList.iterator();
      Subscription nextNode = null;
        Subscription alternativeNextNode = null;
        int index =0;
        while(it.hasNext()){
          index++;
          Subscription temp = it.next();
          if(index == 2){
            alternativeNextNode = temp;
          }
          if(node.equals(temp) && it.hasNext()){
            nextNode = it.next();
View Full Code Here

        Iterator<Subscription> subscriberIter = _subscriptionList.iterator();
        // iterate over all the subscribers, and if they are in advance of this queue entry then move them backwards
        while (subscriberIter.hasNext() && entry.isAvailable())
        {
            Subscription sub = subscriberIter.next();

            // we don't make browsers send the same stuff twice
            if (sub.seesRequeues())
            {
                updateSubRequeueEntry(sub, entry);
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.qpid.server.subscription.Subscription

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.