/** * Since AutoCommitTransaction have no concept of a long lived transaction, any Actions registered * by the caller are executed immediately. */ @Override public void addPostTransactionAction(final Action immediateAction) { addFuture(Futures.<Void>immediateFuture(null), immediateAction); }
public ServerSession(ServerConnection connection, ServerSessionDelegate delegate, Binary name, long expiry) { this.connection = connection; this.delegate = delegate; this.name = name; this.closing = false; this._isNoReplay = false; initReceiver(); _transaction = new AsyncAutoCommitTransaction(this.getMessageStore(),this); _blockingTimeout = connection.getBroker().getContextValue(Long.class, Broker.CHANNEL_FLOW_CONTROL_ENFORCEMENT_TIMEOUT); }
@Override public void dequeue(MessageEnqueueRecord record, Action postTransactionAction) { Transaction txn = null; try { ListenableFuture<Void> future; if(record != null) { LOGGER.debug("Dequeue of message number {} from transaction log. Queue : {}", record.getMessageNumber(), record.getQueueId()); txn = _messageStore.newTransaction(); txn.dequeueMessage(record); future = txn.commitTranAsync((Void) null); txn = null; } else { future = Futures.immediateFuture(null); } addFuture(future, postTransactionAction); postTransactionAction = null; } finally { rollbackIfNecessary(postTransactionAction, txn); } }
addEnqueueFuture(future, new Action() rollbackIfNecessary(new Action()
public SendingLinkEndpoint(final Session_1_0 session, final LinkImpl<Source, Target> link) { super(session, link); setDeliveryCount(new SequenceNumber(0)); setAvailable(UnsignedInteger.valueOf(0)); setCapabilities(Collections.singletonList(AMQPConnection_1_0.SHARED_SUBSCRIPTIONS)); _asyncAutoCommitTransaction = new AsyncAutoCommitTransaction(getSession().getConnection().getAddressSpace().getMessageStore(), this); }
addFuture(future, postTransactionAction); postTransactionAction = null; rollbackIfNecessary(postTransactionAction, txn);
addEnqueueFuture(future, new Action() rollbackIfNecessary(new Action()
public AMQChannel(AMQPConnection_0_8 connection, int channelId, final MessageStore messageStore) { super(connection, channelId); _creditManager = new Pre0_10CreditManager(0L, 0L, connection.getContextValue(Long.class, AMQPConnection_0_8.HIGH_PREFETCH_LIMIT), connection.getContextValue(Long.class, AMQPConnection_0_8.BATCH_LIMIT)); _unacknowledgedMessageMap = new UnacknowledgedMessageMapImpl(DEFAULT_PREFETCH, this); _connection = connection; _channelId = channelId; _messageStore = messageStore; _blockingTimeout = connection.getBroker().getContextValue(Long.class, Broker.CHANNEL_FLOW_CONTROL_ENFORCEMENT_TIMEOUT); // by default the session is non-transactional _transaction = new AsyncAutoCommitTransaction(_messageStore, this); MethodRegistry methodRegistry = _connection.getMethodRegistry(); AMQMethodBody responseBody = methodRegistry.createTxCommitOkBody(); _txCommitOkFrame = new CachedFrame(responseBody.generateFrame(_channelId)); _clientDeliveryMethod = connection.createDeliveryMethod(_channelId); AccessController.doPrivileged((new PrivilegedAction<Object>() { @Override public Object run() { message(ChannelMessages.CREATE()); return null; } }),_accessControllerContext); }
@Override public void commit(final Runnable immediatePostTransactionAction) { if(immediatePostTransactionAction != null) { addFuture(Futures.<Void>immediateFuture(null), new Action() { @Override public void postCommit() { immediatePostTransactionAction.run(); } @Override public void onRollback() { } }); } }
transaction = new AsyncAutoCommitTransaction(getAddressSpace().getMessageStore(), this);