Search in sources :

Example 1 with TimerEntity

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;
}
Also used : TimerEntity(org.camunda.bpm.engine.impl.persistence.entity.TimerEntity)

Example 2 with TimerEntity

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;
        }
    });
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) StringWriter(java.io.StringWriter) TimerEntity(org.camunda.bpm.engine.impl.persistence.entity.TimerEntity) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) JobManager(org.camunda.bpm.engine.impl.persistence.entity.JobManager) Date(java.util.Date) PrintWriter(java.io.PrintWriter)

Example 3 with TimerEntity

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;
        }
    });
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) TimerEntity(org.camunda.bpm.engine.impl.persistence.entity.TimerEntity) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) JobManager(org.camunda.bpm.engine.impl.persistence.entity.JobManager) Date(java.util.Date)

Example 4 with TimerEntity

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();
}
Also used : AcquireJobsCmd(org.camunda.bpm.engine.impl.cmd.AcquireJobsCmd) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) TimerEntity(org.camunda.bpm.engine.impl.persistence.entity.TimerEntity) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) ArrayList(java.util.ArrayList) Date(java.util.Date) JobExecutor(org.camunda.bpm.engine.impl.jobexecutor.JobExecutor) AcquiredJobs(org.camunda.bpm.engine.impl.jobexecutor.AcquiredJobs) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with TimerEntity

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;
}
Also used : TimerEntity(org.camunda.bpm.engine.impl.persistence.entity.TimerEntity)

Aggregations

TimerEntity (org.camunda.bpm.engine.impl.persistence.entity.TimerEntity)8 Date (java.util.Date)4 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)3 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)3 JobManager (org.camunda.bpm.engine.impl.persistence.entity.JobManager)2 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 AcquireJobsCmd (org.camunda.bpm.engine.impl.cmd.AcquireJobsCmd)1 AcquiredJobs (org.camunda.bpm.engine.impl.jobexecutor.AcquiredJobs)1 JobExecutor (org.camunda.bpm.engine.impl.jobexecutor.JobExecutor)1 JobHandlerConfiguration (org.camunda.bpm.engine.impl.jobexecutor.JobHandlerConfiguration)1 Job (org.camunda.bpm.engine.runtime.Job)1 Deployment (org.camunda.bpm.engine.test.Deployment)1