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(); } }); } }
transactionContext.addTransactionListener(TransactionState.COMMITTED, jpaTransactionCommitListener); transactionContext.addTransactionListener(TransactionState.ROLLED_BACK, jpaTransactionRollbackListener);
public Void execute(CommandContext commandContext) { commandContext.getTransactionContext().addTransactionListener(TransactionState.ROLLED_BACK, rolledBackListener); commandContext.getTransactionContext().addTransactionListener(TransactionState.COMMITTED, committedListener); return null; }
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 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); } }
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"); } }); }
@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); }
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); } } } }
protected void hintJobExecutor(JobEntity job) { JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor(); if (!jobExecutor.isActive()) { return; } JobExecutorContext jobExecutorContext = Context.getJobExecutorContext(); TransactionListener transactionListener = null; if(!job.isSuspended() && job.isExclusive() && jobExecutorContext != null && jobExecutorContext.isExecutingExclusiveJob() && areInSameProcessInstance(job, jobExecutorContext.getCurrentJob())) { // lock job & add to the queue of the current processor Date currentTime = ClockUtil.getCurrentTime(); job.setLockExpirationTime(new Date(currentTime.getTime() + jobExecutor.getLockTimeInMillis())); job.setLockOwner(jobExecutor.getLockOwner()); transactionListener = new ExclusiveJobAddedNotification(job.getId(), jobExecutorContext); } else { // notify job executor: transactionListener = new MessageAddedNotification(jobExecutor); } Context.getCommandContext() .getTransactionContext() .addTransactionListener(TransactionState.COMMITTED, transactionListener); }
protected void hintJobExecutor(JobEntity job) { JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor(); if (!jobExecutor.isActive()) { return; } JobExecutorContext jobExecutorContext = Context.getJobExecutorContext(); TransactionListener transactionListener = null; if(!job.isSuspended() && job.isExclusive() && jobExecutorContext != null && jobExecutorContext.isExecutingExclusiveJob() && areInSameProcessInstance(job, jobExecutorContext.getCurrentJob())) { // lock job & add to the queue of the current processor Date currentTime = ClockUtil.getCurrentTime(); job.setLockExpirationTime(new Date(currentTime.getTime() + jobExecutor.getLockTimeInMillis())); job.setLockOwner(jobExecutor.getLockOwner()); transactionListener = new ExclusiveJobAddedNotification(job.getId(), jobExecutorContext); } else { // notify job executor: transactionListener = new MessageAddedNotification(jobExecutor); } Context.getCommandContext() .getTransactionContext() .addTransactionListener(TransactionState.COMMITTED, transactionListener); }