protected CaseSentryPartQueryImpl createCaseSentryPartQuery() { CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequiresNew(); return new CaseSentryPartQueryImpl(commandExecutor); }
protected CaseSentryPartQueryImpl createCaseSentryPartQuery() { CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequiresNew(); return new CaseSentryPartQueryImpl(commandExecutor); }
public void run() { try { processEngineConfiguration.getCommandExecutorTxRequiresNew().execute(command); } catch(RuntimeException e) { command.monitor.setException(e); controlThread.interrupt(); throw e; } } });
protected void setProcessDefinitionVersion(String processInstanceId, int newProcessDefinitionVersion) { CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequiresNew(); commandExecutor.execute(new SetProcessDefinitionVersionCmd(processInstanceId, newProcessDefinitionVersion)); } }
void lockTheJob(final String jobId) { engineRule.getProcessEngineConfiguration().getCommandExecutorTxRequiresNew().execute(new Command<Object>() { @Override public Object execute(CommandContext commandContext) { final JobEntity job = commandContext.getJobManager().findJobById(jobId); job.setLockOwner("someLockOwner"); job.setLockExpirationTime(DateUtils.addHours(ClockUtil.getCurrentTime(), 1)); return null; } }); }
protected CaseSentryPartEntity readCaseSentryPart() { CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequiresNew(); return new CaseSentryPartQueryImpl(commandExecutor).singleResult(); }
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 initIdGenerator() { if (idGenerator == null) { CommandExecutor idGeneratorCommandExecutor = null; if (idGeneratorDataSource != null) { ProcessEngineConfigurationImpl processEngineConfiguration = new StandaloneProcessEngineConfiguration(); processEngineConfiguration.setDataSource(idGeneratorDataSource); processEngineConfiguration.setDatabaseSchemaUpdate(DB_SCHEMA_UPDATE_FALSE); processEngineConfiguration.init(); idGeneratorCommandExecutor = processEngineConfiguration.getCommandExecutorTxRequiresNew(); } else if (idGeneratorDataSourceJndiName != null) { ProcessEngineConfigurationImpl processEngineConfiguration = new StandaloneProcessEngineConfiguration(); processEngineConfiguration.setDataSourceJndiName(idGeneratorDataSourceJndiName); processEngineConfiguration.setDatabaseSchemaUpdate(DB_SCHEMA_UPDATE_FALSE); processEngineConfiguration.init(); idGeneratorCommandExecutor = processEngineConfiguration.getCommandExecutorTxRequiresNew(); } else { idGeneratorCommandExecutor = commandExecutorTxRequiresNew; } DbIdGenerator dbIdGenerator = new DbIdGenerator(); dbIdGenerator.setIdBlockSize(idBlockSize); dbIdGenerator.setCommandExecutor(idGeneratorCommandExecutor); idGenerator = dbIdGenerator; } }
protected void initIdGenerator() { if (idGenerator == null) { CommandExecutor idGeneratorCommandExecutor = null; if (idGeneratorDataSource != null) { ProcessEngineConfigurationImpl processEngineConfiguration = new StandaloneProcessEngineConfiguration(); processEngineConfiguration.setDataSource(idGeneratorDataSource); processEngineConfiguration.setDatabaseSchemaUpdate(DB_SCHEMA_UPDATE_FALSE); processEngineConfiguration.init(); idGeneratorCommandExecutor = processEngineConfiguration.getCommandExecutorTxRequiresNew(); } else if (idGeneratorDataSourceJndiName != null) { ProcessEngineConfigurationImpl processEngineConfiguration = new StandaloneProcessEngineConfiguration(); processEngineConfiguration.setDataSourceJndiName(idGeneratorDataSourceJndiName); processEngineConfiguration.setDatabaseSchemaUpdate(DB_SCHEMA_UPDATE_FALSE); processEngineConfiguration.init(); idGeneratorCommandExecutor = processEngineConfiguration.getCommandExecutorTxRequiresNew(); } else { idGeneratorCommandExecutor = commandExecutorTxRequiresNew; } DbIdGenerator dbIdGenerator = new DbIdGenerator(); dbIdGenerator.setIdBlockSize(idBlockSize); dbIdGenerator.setCommandExecutor(idGeneratorCommandExecutor); idGenerator = dbIdGenerator; } }
protected HistoryCleanupHandler initCleanupHandler(HistoryCleanupJobHandlerConfiguration configuration, CommandContext commandContext) { HistoryCleanupHandler cleanupHandler = null; if (isHistoryCleanupStrategyRemovalTimeBased(commandContext)) { cleanupHandler = new HistoryCleanupRemovalTime(); } else { cleanupHandler = new HistoryCleanupBatch(); } CommandExecutor commandExecutor = commandContext.getProcessEngineConfiguration() .getCommandExecutorTxRequiresNew(); String jobId = commandContext.getCurrentJob().getId(); return cleanupHandler .setConfiguration(configuration) .setCommandExecutor(commandExecutor) .setJobId(jobId); }
protected HistoryCleanupHandler initCleanupHandler(HistoryCleanupJobHandlerConfiguration configuration, CommandContext commandContext) { HistoryCleanupHandler cleanupHandler = null; if (isHistoryCleanupStrategyRemovalTimeBased(commandContext)) { cleanupHandler = new HistoryCleanupRemovalTime(); } else { cleanupHandler = new HistoryCleanupBatch(); } CommandExecutor commandExecutor = commandContext.getProcessEngineConfiguration() .getCommandExecutorTxRequiresNew(); String jobId = commandContext.getCurrentJob().getId(); return cleanupHandler .setConfiguration(configuration) .setCommandExecutor(commandExecutor) .setJobId(jobId); }
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 public void tearDown() throws Exception { ((ProcessEngineConfigurationImpl)processEngine.getProcessEngineConfiguration()).getCommandExecutorTxRequiresNew().execute(new Command<Void>() { public Void execute(CommandContext commandContext) { List<HistoricJobLog> jobLogs = processEngine.getHistoryService().createHistoricJobLogQuery().list(); for (HistoricJobLog jobLog : jobLogs) { commandContext.getHistoricJobLogManager().deleteHistoricJobLogById(jobLog.getId()); } return null; } }); assertEquals(0, processEngine.getHistoryService().createHistoricJobLogQuery().list().size()); super.tearDown(); }
@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 testDeleteByteArray() { final String processDefinitionId = "myProcessDefition"; processEngineConfiguration.getCommandExecutorTxRequiresNew().execute(new Command<Void>() { public Void execute(CommandContext commandContext) { for (int i = 0; i < 1234; i++) { HistoricJobLogEventEntity log = new HistoricJobLogEventEntity(); log.setJobId(String.valueOf(i)); log.setTimestamp(new Date()); log.setJobDefinitionType(MessageEntity.TYPE); log.setProcessDefinitionId(processDefinitionId); byte[] aByteValue = StringUtil.toByteArray("abc"); ByteArrayEntity byteArray = ExceptionUtil.createJobExceptionByteArray(aByteValue, ResourceTypes.HISTORY); log.setExceptionByteArrayId(byteArray.getId()); commandContext .getHistoricJobLogManager() .insert(log); } return null; } }); assertEquals(1234, historyService.createHistoricJobLogQuery().count()); processEngineConfiguration.getCommandExecutorTxRequiresNew().execute(new Command<Void>() { public Void execute(CommandContext commandContext) { commandContext.getHistoricJobLogManager().deleteHistoricJobLogsByProcessDefinitionId(processDefinitionId); return null; } }); assertEquals(0, historyService.createHistoricJobLogQuery().count()); }
Context.getProcessEngineConfiguration().getCommandExecutorTxRequiresNew());
Context.getProcessEngineConfiguration().getCommandExecutorTxRequiresNew());