public void fireExternalTaskAvailableEvent() { Context.getCommandContext() .getTransactionContext() .addTransactionListener(TransactionState.COMMITTED, new TransactionListener() { @Override public void execute(CommandContext commandContext) { ProcessEngineImpl.EXT_TASK_CONDITIONS.signalAll(); } }); } }
public void fireExternalTaskAvailableEvent() { Context.getCommandContext() .getTransactionContext() .addTransactionListener(TransactionState.COMMITTED, new TransactionListener() { @Override public void execute(CommandContext commandContext) { ProcessEngineImpl.EXT_TASK_CONDITIONS.signalAll(); } }); } }
protected boolean isTransactionNotActive() { return !Context.getCommandContext().getTransactionContext().isTransactionActive(); }
protected boolean isTransactionNotActive() { return !Context.getCommandContext().getTransactionContext().isTransactionActive(); }
public Void execute(CommandContext commandContext) { commandContext.getTransactionContext().addTransactionListener(TransactionState.ROLLED_BACK, rolledBackListener); commandContext.getTransactionContext().addTransactionListener(TransactionState.COMMITTED, committedListener); throw new RuntimeException("Booum! Rollback!"); }
public Void execute(CommandContext commandContext) { commandContext.getTransactionContext().addTransactionListener(TransactionState.ROLLED_BACK, rolledBackListener); commandContext.getTransactionContext().addTransactionListener(TransactionState.COMMITTED, committedListener); return null; }
public void notify(final DelegateExecution execution) throws Exception { final String runId = (String) execution.getVariable(PerfTestConstants.RUN_ID); CommandContext commandContext = Context.getCommandContext(); if (runId != null && commandContext != null) { commandContext.getTransactionContext() .addTransactionListener(TransactionState.COMMITTED, new TransactionListener() { public void execute(CommandContext commandContext) { // signal run after the transaction was committed PerfTestRunner.signalRun(runId); } }); } }
protected void notifyAcquisition(CommandContext commandContext) { JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor(); MessageAddedNotification messageAddedNotification = new MessageAddedNotification(jobExecutor); TransactionContext transactionContext = commandContext.getTransactionContext(); transactionContext.addTransactionListener(TransactionState.COMMITTED, messageAddedNotification); } }
protected void notifyAcquisition(CommandContext commandContext) { JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor(); MessageAddedNotification messageAddedNotification = new MessageAddedNotification(jobExecutor); TransactionContext transactionContext = commandContext.getTransactionContext(); transactionContext.addTransactionListener(TransactionState.COMMITTED, messageAddedNotification); } }
@Override public void execute(DelegateExecution execution) throws Exception { Context.getCommandContext().getTransactionContext().addTransactionListener(TransactionState.COMMITTING, new TransactionListener() { @Override public void execute(CommandContext context) { throw new RuntimeException("exception in transaction listener"); } }); }
public void execute(HistoryCleanupJobHandlerConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId) { HistoryCleanupHandler cleanupHandler = initCleanupHandler(configuration, commandContext); if (configuration.isImmediatelyDue() || isWithinBatchWindow(commandContext) ) { cleanupHandler.performCleanup(); } commandContext.getTransactionContext() .addTransactionListener(TransactionState.COMMITTED, cleanupHandler); }
public void execute(HistoryCleanupJobHandlerConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId) { HistoryCleanupHandler cleanupHandler = initCleanupHandler(configuration, commandContext); if (configuration.isImmediatelyDue() || isWithinBatchWindow(commandContext) ) { cleanupHandler.performCleanup(); } commandContext.getTransactionContext() .addTransactionListener(TransactionState.COMMITTED, cleanupHandler); }
@Override public void execute(DelegateExecution execution) throws Exception { Context.getCommandContext().getTransactionContext().addTransactionListener(TransactionState.COMMITTING, new TransactionListener() { @Override public void execute(CommandContext context) { throw new RuntimeException("exception in transaction listener"); } }); }
protected void createJobExecutorRegistrations(Set<String> deploymentIds) { try { final DeploymentFailListener deploymentFailListener = new DeploymentFailListener(deploymentIds, Context.getProcessEngineConfiguration().getCommandExecutorTxRequiresNew()); Context.getCommandContext() .getTransactionContext() .addTransactionListener(TransactionState.ROLLED_BACK, deploymentFailListener); Set<String> registeredDeployments = Context.getProcessEngineConfiguration().getRegisteredDeployments(); registeredDeployments.addAll(deploymentIds); } catch (Exception e) { throw LOG.exceptionWhileRegisteringDeploymentsWithJobExecutor(e); } }
protected void createJobExecutorRegistrations(Set<String> deploymentIds) { try { final DeploymentFailListener deploymentFailListener = new DeploymentFailListener(deploymentIds, Context.getProcessEngineConfiguration().getCommandExecutorTxRequiresNew()); Context.getCommandContext() .getTransactionContext() .addTransactionListener(TransactionState.ROLLED_BACK, deploymentFailListener); Set<String> registeredDeployments = Context.getProcessEngineConfiguration().getRegisteredDeployments(); registeredDeployments.addAll(deploymentIds); } catch (Exception e) { throw LOG.exceptionWhileRegisteringDeploymentsWithJobExecutor(e); } }
protected void registerWithJobExecutor(CommandContext commandContext, DeploymentEntity deployment) { try { new RegisterDeploymentCmd(deployment.getId()).execute(commandContext); } finally { DeploymentFailListener listener = new DeploymentFailListener(deployment.getId(), Context.getProcessEngineConfiguration().getCommandExecutorTxRequiresNew()); try { commandContext.getTransactionContext().addTransactionListener(TransactionState.ROLLED_BACK, listener); } catch (Exception e) { TX_LOG.debugTransactionOperation("Could not register transaction synchronization. Probably the TX has already been rolled back by application code."); listener.execute(commandContext); } } } }
protected void registerWithJobExecutor(CommandContext commandContext, DeploymentEntity deployment) { try { new RegisterDeploymentCmd(deployment.getId()).execute(commandContext); } finally { DeploymentFailListener listener = new DeploymentFailListener(deployment.getId(), Context.getProcessEngineConfiguration().getCommandExecutorTxRequiresNew()); try { commandContext.getTransactionContext().addTransactionListener(TransactionState.ROLLED_BACK, listener); } catch (Exception e) { TX_LOG.debugTransactionOperation("Could not register transaction synchronization. Probably the TX has already been rolled back by application code."); listener.execute(commandContext); } } } }
@Override protected void preExecute(CommandContext commandContext) { if (getJobHandler() instanceof TimerEventJobHandler) { TimerJobConfiguration configuration = (TimerJobConfiguration) getJobHandlerConfiguration(); if (repeat != null && !configuration.isFollowUpJobCreated()) { // this timer is a repeating timer and // a follow up timer job has not been scheduled yet Date newDueDate = calculateRepeat(); if (newDueDate != null) { // the listener is added to the transaction as SYNC on ROLLABCK, // when it is necessary to schedule a new timer job invocation. // If the transaction does not rollback, it is ignored. ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequiresNew(); RepeatingFailedJobListener listener = createRepeatingFailedJobListener(commandExecutor); commandContext.getTransactionContext().addTransactionListener( TransactionState.ROLLED_BACK, listener); // create a new timer job createNewTimerJob(newDueDate); } } } }
@Override protected void preExecute(CommandContext commandContext) { if (getJobHandler() instanceof TimerEventJobHandler) { TimerJobConfiguration configuration = (TimerJobConfiguration) getJobHandlerConfiguration(); if (repeat != null && !configuration.isFollowUpJobCreated()) { // this timer is a repeating timer and // a follow up timer job has not been scheduled yet Date newDueDate = calculateRepeat(); if (newDueDate != null) { // the listener is added to the transaction as SYNC on ROLLABCK, // when it is necessary to schedule a new timer job invocation. // If the transaction does not rollback, it is ignored. ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequiresNew(); RepeatingFailedJobListener listener = createRepeatingFailedJobListener(commandExecutor); commandContext.getTransactionContext().addTransactionListener( TransactionState.ROLLED_BACK, listener); // create a new timer job createNewTimerJob(newDueDate); } } } }
public Void execute(CommandContext commandContext) { DbEntityManagerFactory dbEntityManagerFactory = new DbEntityManagerFactory(Context.getProcessEngineConfiguration().getIdGenerator()); DbEntityManager entityManager = dbEntityManagerFactory.openSession(); JobEntity job = entityManager.selectById(JobEntity.class, JOB_ENTITY_ID); job.setLockOwner(lockOwner); entityManager.forceUpdate(job); monitor.sync(); // flush the changed entity and create a lock for the table entityManager.flush(); monitor.sync(); // commit transaction and remove the lock commandContext.getTransactionContext().commit(); return null; }