use of org.camunda.bpm.engine.impl.persistence.entity.TimerEntity in project camunda-bpm-platform by camunda.
the class TimerDeclarationImpl method createTimer.
public TimerEntity createTimer(String deploymentId) {
TimerEntity timer = super.createJobInstance((ExecutionEntity) null);
timer.setDeploymentId(deploymentId);
scheduleTimer(timer);
return timer;
}
use of org.camunda.bpm.engine.impl.persistence.entity.TimerEntity in project camunda-bpm-platform by camunda.
the class JobQueryTest method createJobWithoutExceptionMsg.
private void createJobWithoutExceptionMsg() {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
JobManager jobManager = commandContext.getJobManager();
timerEntity = new TimerEntity();
timerEntity.setLockOwner(UUID.randomUUID().toString());
timerEntity.setDuedate(new Date());
timerEntity.setRetries(0);
StringWriter stringWriter = new StringWriter();
NullPointerException exception = new NullPointerException();
exception.printStackTrace(new PrintWriter(stringWriter));
timerEntity.setExceptionStacktrace(stringWriter.toString());
jobManager.insert(timerEntity);
assertNotNull(timerEntity.getId());
return null;
}
});
}
use of org.camunda.bpm.engine.impl.persistence.entity.TimerEntity in project camunda-bpm-platform by camunda.
the class JobQueryTest method createJobWithoutExceptionStacktrace.
private void createJobWithoutExceptionStacktrace() {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
JobManager jobManager = commandContext.getJobManager();
timerEntity = new TimerEntity();
timerEntity.setLockOwner(UUID.randomUUID().toString());
timerEntity.setDuedate(new Date());
timerEntity.setRetries(0);
timerEntity.setExceptionMessage("I'm supposed to fail");
jobManager.insert(timerEntity);
assertNotNull(timerEntity.getId());
return null;
}
});
}
use of org.camunda.bpm.engine.impl.persistence.entity.TimerEntity in project camunda-bpm-platform by camunda.
the class JobExecutorCmdHappyTest method testJobCommandsWithTimer.
public void testJobCommandsWithTimer() {
// clock gets automatically reset in LogTestCase.runTest
ClockUtil.setCurrentTime(new Date(SOME_TIME));
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
String jobId = commandExecutor.execute(new Command<String>() {
public String execute(CommandContext commandContext) {
TimerEntity timer = createTweetTimer("i'm coding a test", new Date(SOME_TIME + (10 * SECOND)));
commandContext.getJobManager().schedule(timer);
return timer.getId();
}
});
AcquiredJobs acquiredJobs = commandExecutor.execute(new AcquireJobsCmd(jobExecutor));
List<List<String>> jobIdsList = acquiredJobs.getJobIdBatches();
assertEquals(0, jobIdsList.size());
List<String> expectedJobIds = new ArrayList<String>();
ClockUtil.setCurrentTime(new Date(SOME_TIME + (20 * SECOND)));
acquiredJobs = commandExecutor.execute(new AcquireJobsCmd(jobExecutor, jobExecutor.getMaxJobsPerAcquisition()));
jobIdsList = acquiredJobs.getJobIdBatches();
assertEquals(1, jobIdsList.size());
List<String> jobIds = jobIdsList.get(0);
expectedJobIds.add(jobId);
assertEquals(expectedJobIds, new ArrayList<String>(jobIds));
assertEquals(0, tweetHandler.getMessages().size());
ExecuteJobHelper.executeJob(jobId, commandExecutor);
assertEquals("i'm coding a test", tweetHandler.getMessages().get(0));
assertEquals(1, tweetHandler.getMessages().size());
clearDatabase();
}
use of org.camunda.bpm.engine.impl.persistence.entity.TimerEntity in project camunda-bpm-platform by camunda.
the class JobExecutorTestCase method createTweetTimer.
protected TimerEntity createTweetTimer(String msg, Date duedate) {
TimerEntity timer = new TimerEntity();
timer.setJobHandlerType("tweet");
timer.setJobHandlerConfigurationRaw(msg);
timer.setDuedate(duedate);
return timer;
}
Aggregations