Package org.apache.qpid.server.txn

Examples of org.apache.qpid.server.txn.ServerTransaction


            {
                final List<? extends BaseQueue> rerouteQueues = alternateExchange.route(new InboundMessageAdapter(this));
                final ServerMessage message = getMessage();
                if(rerouteQueues != null && rerouteQueues.size() != 0)
                {
                    ServerTransaction txn = new AutoCommitTransaction(getQueue().getVirtualHost().getTransactionLog());

                    txn.enqueue(rerouteQueues, message, new ServerTransaction.Action() {
                        public void postCommit()
                        {
                            try
                            {
                                for(BaseQueue queue : rerouteQueues)
                                {
                                    queue.enqueue(message);
                                }
                            }
                            catch (AMQException e)
                            {
                                throw new RuntimeException(e);
                            }
                        }

                        public void onRollback()
                        {

                        }
                    });
                    txn.dequeue(currentQueue,message,
                                new ServerTransaction.Action()
                                {
                                    public void postCommit()
                                    {
                                        discard();
View Full Code Here



        // check and deliver if header says body length is zero
        if (currentMessage.allContentReceived())
        {
            ServerTransaction trans = new AutoCommitTransaction(getVirtualHost().getMessageStore());
            final List<? extends BaseQueue> destinationQueues = currentMessage.getDestinationQueues();
            trans.enqueue(currentMessage.getDestinationQueues(), currentMessage, new ServerTransaction.Action() {
                public void postCommit()
                {
                    try
                    {
                        AMQMessage message = new AMQMessage(currentMessage.getStoredMessage());
View Full Code Here

            {
                if (!entry.getDeliveredToConsumer() && entry.acquire())
                {


                    ServerTransaction txn = new LocalTransaction(_messageStore);
                    Collection<QueueEntry> entries = new ArrayList<QueueEntry>(1);
                    entries.add(entry);
                    final AMQMessage message = (AMQMessage) entry.getMessage();
                    txn.dequeue(_queue, entry.getMessage(),
                                new MessageAcknowledgeAction(entries)
                                {
                                    @Override
                                    public void postCommit()
                                    {
                                        try
                                        {
                                            final
                                            ProtocolOutputConverter outputConverter =
                                                    _session.getProtocolOutputConverter();

                                            outputConverter.writeReturn(message.getMessagePublishInfo(),
                                                                        message.getContentHeaderBody(),
                                                                        message,
                                                                        _channelId,
                                                                        AMQConstant.NO_CONSUMERS.getCode(),
                                                                        IMMEDIATE_DELIVERY_REPLY_TEXT);
                                        }
                                        catch (AMQException e)
                                        {
                                            throw new RuntimeException(e);
                                        }
                                        super.postCommit();
                                    }
                                }
                    );
                    txn.commit();


                }

            }
View Full Code Here

        }

        QueueEntryIterator queueListIterator = _entries.iterator();
        long count = 0;

        ServerTransaction txn = new LocalTransaction(getVirtualHost().getMessageStore());

        while (queueListIterator.advance())
        {
            QueueEntry node = queueListIterator.getNode();
            if (node.acquire())
            {
                dequeueEntry(node, txn);
                if(++count == request)
                {
                    break;
                }
            }

        }

        txn.commit();

        return count;
    }
View Full Code Here

        return count;
    }

    private void dequeueEntry(final QueueEntry node)
    {
        ServerTransaction txn = new AutoCommitTransaction(getVirtualHost().getMessageStore());
        dequeueEntry(node, txn);
    }
View Full Code Here

                {
                    return false;
                }
            });

            ServerTransaction txn = new LocalTransaction(getVirtualHost().getMessageStore());

            if(_alternateExchange != null)
            {

                InboundMessageAdapter adapter = new InboundMessageAdapter();
                for(final QueueEntry entry : entries)
                {
                    adapter.setEntry(entry);
                    List<? extends BaseQueue> queues = _alternateExchange.route(adapter);
                    if((queues == null || queues.size() == 0) && _alternateExchange.getAlternateExchange() != null)
                    {
                        queues = _alternateExchange.getAlternateExchange().route(adapter);
                    }

                    final ServerMessage message = entry.getMessage();
                    if(queues != null && queues.size() != 0)
                    {
                        final List<? extends BaseQueue> rerouteQueues = queues;
                        txn.enqueue(rerouteQueues, entry.getMessage(),
                                    new ServerTransaction.Action()
                                    {

                                        public void postCommit()
                                        {
                                            try
                                            {
                                                for(BaseQueue queue : rerouteQueues)
                                                {
                                                    queue.enqueue(message);
                                                }
                                            }
                                            catch (AMQException e)
                                            {
                                                throw new RuntimeException(e);
                                            }

                                        }

                                        public void onRollback()
                                        {

                                        }
                                    });
                        txn.dequeue(this, entry.getMessage(),
                                    new ServerTransaction.Action()
                                    {

                                        public void postCommit()
                                        {
                                            entry.discard();
                                        }

                                        public void onRollback()
                                        {
                                        }
                                    });
                    }

                }

                _alternateExchange.removeReference(this);
            }
            else
            {
                // TODO log discard

                for(final QueueEntry entry : entries)
                {
                    final ServerMessage message = entry.getMessage();
                    if(message != null)
                    {
                        txn.dequeue(this, message,
                                    new ServerTransaction.Action()
                                    {

                                        public void postCommit()
                                        {
                                            entry.discard();
                                        }

                                        public void onRollback()
                                        {
                                        }
                                    });
                    }
                }
            }

            txn.commit();

            for (Task task : _deleteTaskList)
            {
                task.doTask(this);
            }
View Full Code Here


        // check and deliver if header says body length is zero
        if (currentMessage.allContentReceived())
        {
            ServerTransaction trans = new AutoCommitTransaction(getVirtualHost().getMessageStore());
            final List<? extends BaseQueue> destinationQueues = currentMessage.getDestinationQueues();
            trans.enqueue(currentMessage.getDestinationQueues(), currentMessage, new ServerTransaction.Action() {
                public void postCommit()
                {
                    try
                    {
                        AMQMessage message = new AMQMessage(currentMessage.getStoredMessage());
View Full Code Here

    }

    public ServerTransaction getTransaction(Binary transactionId)
    {
        // TODO should treat invalid id differently to null
        ServerTransaction transaction = _openTransactions.get(binaryToInteger(transactionId));
        return transaction == null ? _transaction : transaction;
    }
View Full Code Here

            ArrayList<AMQQueue> qs = new ArrayList<AMQQueue>();
            qs.add(_queue);
            MessageMetaData mmd = new MessageMetaData(publishBody,cb, System.currentTimeMillis());
            final StoredMessage storedMessage = _messageStore.addMessage(mmd);
            final AMQMessage message = new AMQMessage(storedMessage);
            ServerTransaction txn = new AutoCommitTransaction(_messageStore);
            txn.enqueue(_queue, message,
                        new ServerTransaction.Action()
                        {
                            public void postCommit()
                            {
                                _queue.enqueue(message,null);
View Full Code Here

        }
    }

    private void forceDequeue(final QueueEntry entry, final boolean restoreCredit)
    {
        ServerTransaction txn = new AutoCommitTransaction(getQueue().getVirtualHost().getTransactionLog());
        txn.dequeue(entry.getQueue(),entry.getMessage(),
                                new ServerTransaction.Action()
                            {
                                public void postCommit()
                                {
                                    if(restoreCredit)
View Full Code Here

TOP

Related Classes of org.apache.qpid.server.txn.ServerTransaction

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.