use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class DeploymentAwareJobExecutorTest method testJobsWithoutDeploymentIdAreAlwaysProcessed.
public void testJobsWithoutDeploymentIdAreAlwaysProcessed() {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
String messageId = commandExecutor.execute(new Command<String>() {
public String execute(CommandContext commandContext) {
MessageEntity message = new MessageEntity();
commandContext.getJobManager().send(message);
return message.getId();
}
});
AcquiredJobs acquiredJobs = getExecutableJobs(processEngineConfiguration.getJobExecutor());
Assert.assertEquals(1, acquiredJobs.size());
Assert.assertTrue(acquiredJobs.contains(messageId));
commandExecutor.execute(new DeleteJobsCmd(messageId, true));
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class AbstractPaLocalScriptEngineTest method getProcessApplication.
protected ProcessApplicationInterface getProcessApplication() {
ProcessApplicationReference reference = processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<ProcessApplicationReference>() {
public ProcessApplicationReference execute(CommandContext commandContext) {
ProcessDefinitionEntity definition = commandContext.getProcessDefinitionManager().findLatestProcessDefinitionByKey(PROCESS_ID);
String deploymentId = definition.getDeploymentId();
ProcessApplicationManager processApplicationManager = processEngineConfiguration.getProcessApplicationManager();
return processApplicationManager.getProcessApplicationForDeployment(deploymentId);
}
});
assertNotNull(reference);
ProcessApplicationInterface processApplication = null;
try {
processApplication = reference.getProcessApplication();
} catch (ProcessApplicationUnavailableException e) {
fail("Could not retrieve process application");
}
return processApplication.getRawObject();
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class SendSignalDelegate method execute.
public void execute(DelegateExecution execution) throws Exception {
businessProcess.setVariable("processName", "throwSignal-visited (was " + businessProcess.getVariable("processName") + ")");
String signalProcessInstanceId = (String) execution.getVariable("signalProcessInstanceId");
String executionId = runtimeService.createExecutionQuery().processInstanceId(signalProcessInstanceId).signalEventSubscriptionName("alert").singleResult().getId();
CommandContext commandContext = Context.getCommandContext();
List<EventSubscriptionEntity> findSignalEventSubscriptionsByEventName = commandContext.getEventSubscriptionManager().findSignalEventSubscriptionsByNameAndExecution("alert", executionId);
for (EventSubscriptionEntity signalEventSubscriptionEntity : findSignalEventSubscriptionsByEventName) {
signalEventSubscriptionEntity.eventReceived(null, true);
}
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class SignalTestRunListener method notify.
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);
}
});
}
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class HistoricJobLogTest method testDeleteByteArray.
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);
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());
}
Aggregations