Search in sources :

Example 6 with AutoCommitTransaction

use of org.apache.qpid.server.txn.AutoCommitTransaction in project qpid-broker-j by apache.

the class AbstractQueue method dequeueEntry.

private void dequeueEntry(final QueueEntry node) {
    ServerTransaction txn = new AutoCommitTransaction(getVirtualHost().getMessageStore());
    dequeueEntry(node, txn);
}
Also used : AutoCommitTransaction(org.apache.qpid.server.txn.AutoCommitTransaction) ServerTransaction(org.apache.qpid.server.txn.ServerTransaction)

Example 7 with AutoCommitTransaction

use of org.apache.qpid.server.txn.AutoCommitTransaction in project qpid-broker-j by apache.

the class AbstractVirtualHost method executeTransaction.

@Override
public void executeTransaction(TransactionalOperation op) {
    final MessageStore store = getMessageStore();
    final LocalTransaction txn = new LocalTransaction(store);
    op.withinTransaction(new Transaction() {

        @Override
        public void dequeue(final QueueEntry messageInstance) {
            final ServerTransaction.Action deleteAction = new ServerTransaction.Action() {

                @Override
                public void postCommit() {
                    messageInstance.delete();
                }

                @Override
                public void onRollback() {
                }
            };
            boolean acquired = messageInstance.acquireOrSteal(new Runnable() {

                @Override
                public void run() {
                    ServerTransaction txn = new AutoCommitTransaction(store);
                    txn.dequeue(messageInstance.getEnqueueRecord(), deleteAction);
                }
            });
            if (acquired) {
                txn.dequeue(messageInstance.getEnqueueRecord(), deleteAction);
            }
        }

        @Override
        public void copy(QueueEntry entry, final Queue<?> queue) {
            final ServerMessage message = entry.getMessage();
            txn.enqueue(queue, message, new ServerTransaction.EnqueueAction() {

                @Override
                public void postCommit(MessageEnqueueRecord... records) {
                    queue.enqueue(message, null, records[0]);
                }

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

        @Override
        public void move(final QueueEntry entry, final Queue<?> queue) {
            final ServerMessage message = entry.getMessage();
            if (entry.acquire()) {
                txn.enqueue(queue, message, new ServerTransaction.EnqueueAction() {

                    @Override
                    public void postCommit(MessageEnqueueRecord... records) {
                        queue.enqueue(message, null, records[0]);
                    }

                    @Override
                    public void onRollback() {
                        entry.release();
                    }
                });
                txn.dequeue(entry.getEnqueueRecord(), new ServerTransaction.Action() {

                    @Override
                    public void postCommit() {
                        entry.delete();
                    }

                    @Override
                    public void onRollback() {
                    }
                });
            }
        }
    });
    txn.commit();
}
Also used : MessageStore(org.apache.qpid.server.store.MessageStore) AutoCommitTransaction(org.apache.qpid.server.txn.AutoCommitTransaction) PrivilegedAction(java.security.PrivilegedAction) LocalTransaction(org.apache.qpid.server.txn.LocalTransaction) ServerMessage(org.apache.qpid.server.message.ServerMessage) MessageEnqueueRecord(org.apache.qpid.server.store.MessageEnqueueRecord) QueueEntry(org.apache.qpid.server.queue.QueueEntry) AutoCommitTransaction(org.apache.qpid.server.txn.AutoCommitTransaction) LocalTransaction(org.apache.qpid.server.txn.LocalTransaction) ServerTransaction(org.apache.qpid.server.txn.ServerTransaction) ServerTransaction(org.apache.qpid.server.txn.ServerTransaction)

Example 8 with AutoCommitTransaction

use of org.apache.qpid.server.txn.AutoCommitTransaction in project qpid-broker-j by apache.

the class ConsumerTarget_0_10 method forceDequeue.

private void forceDequeue(final MessageInstance entry, final boolean restoreCredit) {
    AutoCommitTransaction dequeueTxn = new AutoCommitTransaction(_session.getAddressSpace().getMessageStore());
    dequeueTxn.dequeue(entry.getEnqueueRecord(), new ServerTransaction.Action() {

        @Override
        public void postCommit() {
            if (restoreCredit) {
                restoreCredit(entry.getMessage());
            }
            entry.delete();
        }

        @Override
        public void onRollback() {
        }
    });
}
Also used : AutoCommitTransaction(org.apache.qpid.server.txn.AutoCommitTransaction) ServerTransaction(org.apache.qpid.server.txn.ServerTransaction)

Aggregations

AutoCommitTransaction (org.apache.qpid.server.txn.AutoCommitTransaction)8 ServerTransaction (org.apache.qpid.server.txn.ServerTransaction)6 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 MessageDestination (org.apache.qpid.server.message.MessageDestination)2 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)2 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)2 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)2 Outcome (org.apache.qpid.server.protocol.v1_0.type.Outcome)2 AsyncAutoCommitTransaction (org.apache.qpid.server.txn.AsyncAutoCommitTransaction)2 LocalTransaction (org.apache.qpid.server.txn.LocalTransaction)2 Serializable (java.io.Serializable)1 AccessControlException (java.security.AccessControlException)1 PrivilegedAction (java.security.PrivilegedAction)1 ArrayList (java.util.ArrayList)1 Collections.newSetFromMap (java.util.Collections.newSetFromMap)1 Date (java.util.Date)1 List (java.util.List)1 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)1