Package org.apache.qpid.server.message

Examples of org.apache.qpid.server.message.MessageInstance$DeletedState


        {
            collect(deliveryTag, msgs);
        }
        else
        {
            final MessageInstance entry = get(deliveryTag);
            if(entry != null)
            {
                msgs.put(deliveryTag, entry);
            }
        }
View Full Code Here


    public MessageInstance remove(long deliveryTag)
    {
        synchronized (_lock)
        {

            MessageInstance message = _map.remove(deliveryTag);
            if(message != null)
            {
                _unackedSize -= message.getMessage().getSize();

            }

            return message;
        }
View Full Code Here

                          " on channel:" + channel.debugIdentity());
        }

        long deliveryTag = body.getDeliveryTag();

        MessageInstance message = channel.getUnacknowledgedMessageMap().get(deliveryTag);

        if (message == null)
        {
            _logger.warn("Dropping reject request as message is null for tag:" + deliveryTag);
        }
        else
        {

            if (message.getMessage() == null)
            {
                _logger.warn("Message has already been purged, unable to Reject.");
                return;
            }


            if (_logger.isDebugEnabled())
            {
                _logger.debug("Rejecting: DT:" + deliveryTag + "-" + message.getMessage() +
                              ": Requeue:" + body.getRequeue() +
                              " on channel:" + channel.debugIdentity());
            }

            if (body.getRequeue())
            {
                //this requeue represents a message rejected from the pre-dispatch queue
                //therefore we need to amend the delivery counter.
                message.decrementDeliveryCount();

                channel.requeue(deliveryTag);
            }
            else
            {
                // Since the Java client abuses the reject flag for requeing after rollback, we won't set reject here
                // as it would prevent redelivery
                // message.reject();

                final boolean maxDeliveryCountEnabled = channel.isMaxDeliveryCountEnabled(deliveryTag);
                _logger.debug("maxDeliveryCountEnabled: " + maxDeliveryCountEnabled + " deliveryTag " + deliveryTag);
                if (maxDeliveryCountEnabled)
                {
                    final boolean deliveredTooManyTimes = channel.isDeliveredTooManyTimes(deliveryTag);
                    _logger.debug("deliveredTooManyTimes: " + deliveredTooManyTimes + " deliveryTag " + deliveryTag);
                    if (deliveredTooManyTimes)
                    {
                        channel.deadLetter(body.getDeliveryTag());
                    }
                    else
                    {
                        //this requeue represents a message rejected because of a recover/rollback that we
                        //are not ready to DLQ. We rely on the reject command to resend from the unacked map
                        //and therefore need to increment the delivery counter so we cancel out the effect
                        //of the AMQChannel#resend() decrement.
                        message.incrementDeliveryCount();
                    }
                }
                else
                {
                    channel.requeue(deliveryTag);
View Full Code Here

        return msgs;
    }

    private MessageInstance createMessageInstance(final int id)
    {
        MessageInstance instance = mock(MessageInstance.class);
        when(instance.lockAcquisition()).thenReturn(Boolean.TRUE);
        return instance;
    }
View Full Code Here

        int i = 1;
        for (long deliveryTag : deliveryTagSet)
        {
            assertTrue(deliveryTag == i);
            i++;
            MessageInstance unackedMsg = map.get(deliveryTag);
            assertTrue(unackedMsg.getOwningResource() == _queue);
        }

    }
View Full Code Here

        Set<Long> deliveryTagSet = map.getDeliveryTags();
        int i = 1;
        for (long deliveryTag : deliveryTagSet)
        {
            assertTrue(deliveryTag == i);
            MessageInstance unackedMsg = map.get(deliveryTag);
            assertTrue(unackedMsg.getOwningResource() == _queue);
            // 5 is the delivery tag of the message that *should* be removed
            if (++i == 5)
            {
                ++i;
            }
View Full Code Here

        Set<Long> deliveryTagSet = map.getDeliveryTags();
        int i = 1;
        for (long deliveryTag : deliveryTagSet)
        {
            assertTrue(deliveryTag == i + 5);
            MessageInstance unackedMsg = map.get(deliveryTag);
            assertTrue(unackedMsg.getOwningResource() == _queue);
            ++i;
        }
    }
View Full Code Here

        Set<Long> deliveryTagSet = map.getDeliveryTags();
        int i = 1;
        for (long deliveryTag : deliveryTagSet)
        {
            assertTrue(deliveryTag == i + 5);
            MessageInstance unackedMsg = map.get(deliveryTag);
            assertTrue(unackedMsg.getOwningResource() == _queue);
            ++i;
        }
    }
View Full Code Here

        _resumeFullTransfers.clear();

        for(Map.Entry<Binary, MessageInstance> entry : unsettledCopy.entrySet())
        {
            Binary deliveryTag = entry.getKey();
            final MessageInstance queueEntry = entry.getValue();
            if(initialUnsettledMap == null || !initialUnsettledMap.containsKey(deliveryTag))
            {
                queueEntry.setRedelivered();
                queueEntry.release();
                _unsettledMap.remove(deliveryTag);
            }
            else if(initialUnsettledMap.get(deliveryTag) instanceof Outcome)
            {
                Outcome outcome = (Outcome) initialUnsettledMap.get(deliveryTag);

                if(outcome instanceof Accepted)
                {
                    AutoCommitTransaction txn = new AutoCommitTransaction(_vhost.getMessageStore());
                    if(_consumer.acquires())
                    {
                        if(queueEntry.acquire() || queueEntry.isAcquired())
                        {
                            txn.dequeue(Collections.singleton(queueEntry),
                                        new ServerTransaction.Action()
                                        {
                                            public void postCommit()
                                            {
                                                queueEntry.delete();
                                            }

                                            public void onRollback()
                                            {
                                            }
                                        });
                        }
                    }
                }
                else if(outcome instanceof Released)
                {
                    AutoCommitTransaction txn = new AutoCommitTransaction(_vhost.getMessageStore());
                    if(_consumer.acquires())
                    {
                        txn.dequeue(Collections.singleton(queueEntry),
                                new ServerTransaction.Action()
                                {
                                    public void postCommit()
                                    {
                                        queueEntry.release();
                                    }

                                    public void onRollback()
                                    {
                                        //To change body of implemented methods use File | Settings | File Templates.
View Full Code Here

     * @param deliveryTag The message to requeue
     *
     */
    public void requeue(long deliveryTag)
    {
        MessageInstance unacked = _unacknowledgedMessageMap.remove(deliveryTag);

        if (unacked != null)
        {
            // Mark message redelivered
            unacked.setRedelivered();

            // Ensure message is released for redelivery
            unacked.release();

        }
        else
        {
            _logger.warn("Requested requeue of message:" + deliveryTag + " but no such delivery tag exists."
View Full Code Here

TOP

Related Classes of org.apache.qpid.server.message.MessageInstance$DeletedState

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.