@Override public void commit() throws Exception { super.commit(); }
/** * @return */ @Override public Transaction newTransaction() { return new TransactionImpl(null, storageManager, timeoutSeconds); }
@Override public boolean hasTimedOut(final long currentTime, final int defaultTimeout) { synchronized (timeoutLock) { boolean timedout; if (timeoutSeconds == -1) { timedout = getState() != Transaction.State.PREPARED && currentTime > createTime + (long) defaultTimeout * 1000; } else { timedout = getState() != Transaction.State.PREPARED && currentTime > createTime + (long) timeoutSeconds * 1000; } if (timedout) { markAsRollbackOnly(new ActiveMQTransactionTimeoutException()); } return timedout; } }
try { synchronized (timeoutLock) { if (isEffective()) { logger.debug("TransactionImpl::prepare::" + this + " is being ignored"); return; internalRollback(); beforePrepare();
@Test public void testDuplicateNonPersistent() throws Exception { createStorage(); DuplicateIDCache cache = new DuplicateIDCacheImpl(new SimpleString("test"), 2000, journal, false); TransactionImpl tx = new TransactionImpl(journal); for (int i = 0; i < 5000; i++) { byte[] bytes = RandomUtil.randomBytes(); cache.addToCache(bytes, tx); } tx.commit(); for (int i = 0; i < 5000; i++) { byte[] bytes = RandomUtil.randomBytes(); cache.addToCache(bytes, null); } } }
@Test public void testTimeoutAndThenCommitWithARollback() throws Exception { TransactionImpl tx = new TransactionImpl(newXID(), new FakeSM(), 10); Assert.assertTrue(tx.hasTimedOut(System.currentTimeMillis() + 60000, 10)); tx.addOperation(new TransactionOperation() { @Override public void beforePrepare(Transaction tx) throws Exception { tx.commit(); Assert.fail("Exception expected!"); } catch (ActiveMQException expected) { tx.rollback();
@Test public void testTimeoutThenRollbackWithRollback() throws Exception { TransactionImpl tx = new TransactionImpl(newXID(), new FakeSM(), 10); Assert.assertTrue(tx.hasTimedOut(System.currentTimeMillis() + 60000, 10)); tx.addOperation(new TransactionOperation() { @Override public void beforePrepare(Transaction tx) throws Exception { tx.rollback(); tx.markAsRollbackOnly(new ActiveMQException("rollback only again")); tx.rollback();
@Override public void rollback() throws Exception { super.rollback(); }
TransactionImpl tx = new TransactionImpl(journal); tx.commit(); tx = new TransactionImpl(journal); tx.commit();
@Override public void rollback() throws Exception { super.rollback(); }
/** * @param xid * @return */ private Transaction newTransaction(final Xid xid) { return new TransactionImpl(xid, storageManager, timeoutSeconds); }
TransactionImpl tx = new TransactionImpl(server1.getStorageManager()); for (long id : ids) { byte[] duplicateArray = BridgeImpl.getDuplicateBytes(server0.getNodeManager().getUUID(), id); duplicateTargetCache.addToCache(duplicateArray, tx); tx.commit();
@Override public void commit() throws Exception { commit(true); }
private void purgeAfterRollback(LinkedList<MessageReference> refs) { try { Transaction transaction = new TransactionImpl(storageManager); for (MessageReference reference : refs) { incDelivering(reference); // post ack will decrement this, so need to inc acknowledge(transaction, reference, AckReason.KILLED, null); } transaction.commit(); } catch (Exception e) { logger.warn(e.getMessage(), e); } }
@Override public void commit() throws Exception { super.commit(); // Settle all unsettled deliveries if commit is successful for (Pair<Delivery, ProtonServerSenderContext> p : deliveries.values()) { if (!p.getA().isSettled()) p.getB().settle(p.getA()); } }
@Override public void ack(final PagedReference reference) throws Exception { // Need to do the ACK and counter atomically (inside a TX) or the counter could get out of sync Transaction tx = new TransactionImpl(this.store); ackTx(tx, reference); tx.commit(); }
@Override public void delete() throws Exception { Transaction tx = new TransactionImpl(storage); delete(tx); tx.commit(); }
Transaction txRecoverCounter = new TransactionImpl(storageManager);
tx = new TransactionImpl(storageManager);