public boolean begin() { if (nestedTransactions || getStatus() != TransactionManager.STATUS_ACTIVE) { try { currentTransaction.push(this.ptm.getTransaction(td)); return true; } catch (Exception e) { logger.warn("Unable to begin transaction", e); throw new RuntimeException("Unable to begin transaction", e); } } return false; }
public boolean begin() { if (nestedTransactions || getStatus() != TransactionManager.STATUS_ACTIVE) { try { currentTransaction.push(this.ptm.getTransaction(td)); return true; } catch (Exception e) { logger.warn("Unable to begin transaction", e); throw new RuntimeException("Unable to begin transaction", e); } } return false; }
public boolean begin() { if( nestedTransactions || getStatus() != TransactionManager.STATUS_ACTIVE ) { try { currentTransaction.push(this.ptm.getTransaction( td )); return true; } catch ( Exception e ) { logger.warn( "Unable to begin transaction", e ); throw new RuntimeException( "Unable to begin transaction", e ); } } return false; }
public boolean begin() { if( nestedTransactions || getStatus() != TransactionManager.STATUS_ACTIVE ) { try { currentTransaction.push(this.ptm.getTransaction( td )); return true; } catch ( Exception e ) { logger.warn( "Unable to begin transaction", e ); throw new RuntimeException( "Unable to begin transaction", e ); } } return false; }
public boolean begin() { if( nestedTransactions || getStatus() != TransactionManager.STATUS_ACTIVE ) { try { currentTransaction.push(this.ptm.getTransaction( td )); return true; } catch ( Exception e ) { logger.warn( "Unable to begin transaction", e ); throw new RuntimeException( "Unable to begin transaction", e ); } } return false; }
public boolean begin() { try { if ( getStatus() == TransactionManager.STATUS_NO_TRANSACTION ) { // If there is no transaction then start one, we will commit within the same Command // it seems in spring calling getTransaction is enough to begin a new transaction currentTransaction = this.ptm.getTransaction( td ); return true; } else { return false; } } catch ( Exception e ) { logger.warn( "Unable to begin transaction", e ); throw new RuntimeException( "Unable to begin transaction", e ); } }
public boolean begin() { try { if ( getStatus() == TransactionManager.STATUS_NO_TRANSACTION ) { // If there is no transaction then start one, we will commit within the same Command // it seems in spring calling getTransaction is enough to begin a new transaction currentTransaction = this.ptm.getTransaction( td ); return true; } else { return false; } } catch ( Exception e ) { logger.warn( "Unable to begin transaction", e ); throw new RuntimeException( "Unable to begin transaction", e ); } }
public boolean begin() { try { if (getStatus() == TransactionManager.STATUS_NO_TRANSACTION) { // If there is no transaction then start one, we will commit within the same Command // it seems in spring calling getTransaction is enough to begin a new transaction currentTransaction = this.ptm.getTransaction(td); return true; } else { return false; } } catch (Exception e) { logger.warn("Unable to begin transaction", e); throw new RuntimeException("Unable to begin transaction", e); } }
public boolean begin() { try { if ( getStatus() == TransactionManager.STATUS_NO_TRANSACTION ) { // If there is no transaction then start one, we will commit within the same Command // it seems in spring calling getTransaction is enough to begin a new transaction currentTransaction = this.ptm.getTransaction( td ); return true; } else { return false; } } catch ( Exception e ) { logger.warn( "Unable to begin transaction", e ); throw new RuntimeException( "Unable to begin transaction", e ); } }
public boolean begin() { try { if (getStatus() == TransactionManager.STATUS_NO_TRANSACTION) { // If there is no transaction then start one, we will commit within the same Command // it seems in spring calling getTransaction is enough to begin a new transaction currentTransaction = this.ptm.getTransaction(td); return true; } else { return false; } } catch (Exception e) { logger.warn("Unable to begin transaction", e); throw new RuntimeException("Unable to begin transaction", e); } }
@Override public <T> T execute(Command<T> command) { TransactionStatus status = transactionManager.getTransaction(defTransDefinition); try { T result = super.execute(command); transactionManager.commit(status); return result; } catch (Throwable e) { transactionManager.rollback(status); throw new RuntimeException(e); } }
@Override public <T> T execute(Command<T> command) { TransactionStatus status = transactionManager.getTransaction(defTransDefinition); try { T result = super.execute(command); transactionManager.commit(status); return result; } catch (Throwable e) { transactionManager.rollback(status); throw new RuntimeException(e); } }
try { if ( currentTransaction.size() == 0 ) { transaction = ptm.getTransaction(td); currentTransaction.push(transaction); commitNewTransaction = true;
try { if ( currentTransaction.size() == 0 ) { transaction = ptm.getTransaction(td); currentTransaction.push(transaction); commitNewTransaction = true;
@Override public void run() { TransactionStatus status = transactionManager.getTransaction(defTransDefinition); log.debug("Attempting to abort to lock process instance for 3 secs "); // getProcessInstance does not lock reliably so let's make a change that actually does something to the entity ksession.abortProcessInstance(processInstance.getId()); // let thread 2 start once we have the transaction txAcquiredSignal.countDown(); try { // keep the lock until thread 2 let's us know it's done pessLockExceptionSignal.await(); } catch (InterruptedException e) { // do nothing } log.debug("Commited process instance aborting after 3 secs"); transactionManager.commit(status); // let main test thread know we're done threadsAreDoneLatch.countDown(); } };
@Override public void run() { TransactionStatus status = transactionManager.getTransaction(defTransDefinition); log.debug("Attempting to abort to lock process instance for 3 secs "); // getProcessInstance does not lock reliably so let's make a change that actually does something to the entity ksession.abortProcessInstance(processInstance.getId()); // let thread 2 start once we have the transaction txAcquiredSignal.countDown(); try { // keep the lock until thread 2 let's us know it's done pessLockExceptionSignal.await(); } catch (InterruptedException e) { // do nothing } log.debug("Commited process instance aborting after 3 secs"); transactionManager.commit(status); // let main test thread know we're done threadsAreDoneLatch.countDown(); } };
try { if ( currentTransaction == null ) { transaction = ptm.getTransaction( td ); if ( transaction.isNewTransaction() ) { return TransactionManager.STATUS_COMMITTED;
try { if ( currentTransaction == null ) { transaction = ptm.getTransaction( td ); if ( transaction.isNewTransaction() ) { return TransactionManager.STATUS_COMMITTED;
@Test public void testSimpleTaskInvocationWithRollback() throws Exception{ AbstractPlatformTransactionManager transactionManager = getTransactionManager(); RuntimeManager manager = getManager(); RuntimeEngine engine = getEngine(); KieSession ksession = getKieSession(); AuditLogService logService = getLogService(); DefaultTransactionDefinition def = new DefaultTransactionDefinition(); TransactionStatus status = transactionManager.getTransaction(def); ProcessInstance processInstance = ksession.startProcess(SAMPLE_HELLO_PROCESS_ID); long processInstanceId = processInstance.getId(); transactionManager.rollback(status); processInstance = ksession.getProcessInstance(processInstanceId); assertNull("Process instance not rolled back", processInstance); System.out.println("Process instance rolled back"); List<TaskSummary> tasks = getTaskService().getTasksAssignedAsPotentialOwner(USER_JOHN, "en-UK"); System.out.println("Found " + tasks.size() + " task(s) for user '"+USER_JOHN+"'"); assertEquals(0, tasks.size()); ProcessInstanceLog log = logService.findProcessInstance(processInstanceId); assertNull(log); manager.disposeRuntimeEngine(engine); } }
@Test public void testSimpleTaskInvocationWithRollback() throws Exception{ AbstractPlatformTransactionManager transactionManager = getTransactionManager(); RuntimeManager manager = getManager(); RuntimeEngine engine = getEngine(); KieSession ksession = getKieSession(); AuditLogService logService = getLogService(); DefaultTransactionDefinition def = new DefaultTransactionDefinition(); TransactionStatus status = transactionManager.getTransaction(def); ProcessInstance processInstance = ksession.startProcess(SAMPLE_HELLO_PROCESS_ID); long processInstanceId = processInstance.getId(); transactionManager.rollback(status); processInstance = ksession.getProcessInstance(processInstanceId); assertNull("Process instance not rolled back", processInstance); System.out.println("Process instance rolled back"); List<TaskSummary> tasks = getTaskService().getTasksAssignedAsPotentialOwner(USER_JOHN, "en-UK"); System.out.println("Found " + tasks.size() + " task(s) for user '"+USER_JOHN+"'"); assertEquals(0, tasks.size()); ProcessInstanceLog log = logService.findProcessInstance(processInstanceId); assertNull(log); manager.disposeRuntimeEngine(engine); } }