use of org.camunda.bpm.engine.impl.persistence.entity.MessageEntity in project camunda-bpm-platform by camunda.
the class EventSubscriptionJobDeclaration method newJobInstance.
protected MessageEntity newJobInstance(EventSubscriptionEntity eventSubscription) {
MessageEntity message = new MessageEntity();
// initialize job
message.setActivityId(eventSubscription.getActivityId());
message.setExecutionId(eventSubscription.getExecutionId());
message.setProcessInstanceId(eventSubscription.getProcessInstanceId());
ProcessDefinitionEntity processDefinition = eventSubscription.getProcessDefinition();
if (processDefinition != null) {
message.setProcessDefinitionId(processDefinition.getId());
message.setProcessDefinitionKey(processDefinition.getKey());
}
return message;
}
use of org.camunda.bpm.engine.impl.persistence.entity.MessageEntity in project camunda-bpm-platform by camunda.
the class AsyncTaskTest method testFailingAsyncServiceTimer.
@Deployment
public void testFailingAsyncServiceTimer() {
// start process
runtimeService.startProcessInstanceByKey("asyncService");
// now there should be one job in the database, and it is a message
assertEquals(1, managementService.createJobQuery().count());
Job job = managementService.createJobQuery().singleResult();
if (!(job instanceof MessageEntity)) {
fail("the job must be a message");
}
executeAvailableJobs();
// the service failed: the execution is still sitting in the service task:
Execution execution = runtimeService.createExecutionQuery().singleResult();
assertNotNull(execution);
assertEquals("service", runtimeService.getActiveActivityIds(execution.getId()).get(0));
// there is still a single job because the timer was created in the same transaction as the
// service was executed (which rolled back)
assertEquals(1, managementService.createJobQuery().count());
runtimeService.deleteProcessInstance(execution.getId(), "dead");
}
use of org.camunda.bpm.engine.impl.persistence.entity.MessageEntity in project camunda-bpm-platform by camunda.
the class MessageJobDeclaration method newJobInstance.
@Override
protected MessageEntity newJobInstance(AtomicOperationInvocation context) {
MessageEntity message = new MessageEntity();
message.setExecution(context.getExecution());
return message;
}
use of org.camunda.bpm.engine.impl.persistence.entity.MessageEntity in project camunda-bpm-platform by camunda.
the class ManagementServiceTest method createJob.
protected void createJob(final int retries, final String owner, final Date lockExpirationTime) {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Void>() {
@Override
public Void execute(CommandContext commandContext) {
JobManager jobManager = commandContext.getJobManager();
MessageEntity job = new MessageEntity();
job.setJobHandlerType("any");
job.setLockOwner(owner);
job.setLockExpirationTime(lockExpirationTime);
job.setRetries(retries);
jobManager.send(job);
return null;
}
});
}
use of org.camunda.bpm.engine.impl.persistence.entity.MessageEntity in project camunda-bpm-platform by camunda.
the class JobQueryTest method setUp.
/**
* Setup will create
* - 3 process instances, each with one timer, each firing at t1/t2/t3 + 1 hour (see process)
* - 1 message
*/
protected void setUp() throws Exception {
super.setUp();
this.commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
deploymentId = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/timerOnTask.bpmn20.xml").deploy().getId();
// Create proc inst that has timer that will fire on t1 + 1 hour
Calendar startTime = Calendar.getInstance();
startTime.set(Calendar.MILLISECOND, 0);
Date t1 = startTime.getTime();
ClockUtil.setCurrentTime(t1);
processInstanceIdOne = runtimeService.startProcessInstanceByKey("timerOnTask").getId();
testStartTime = t1;
timerOneFireTime = new Date(t1.getTime() + ONE_HOUR);
// Create proc inst that has timer that will fire on t2 + 1 hour
startTime.add(Calendar.HOUR_OF_DAY, 1);
// t2 = t1 + 1 hour
Date t2 = startTime.getTime();
ClockUtil.setCurrentTime(t2);
processInstanceIdTwo = runtimeService.startProcessInstanceByKey("timerOnTask").getId();
timerTwoFireTime = new Date(t2.getTime() + ONE_HOUR);
// Create proc inst that has timer that will fire on t3 + 1 hour
startTime.add(Calendar.HOUR_OF_DAY, 1);
// t3 = t2 + 1 hour
Date t3 = startTime.getTime();
ClockUtil.setCurrentTime(t3);
processInstanceIdThree = runtimeService.startProcessInstanceByKey("timerOnTask").getId();
timerThreeFireTime = new Date(t3.getTime() + ONE_HOUR);
// Create one message
messageId = commandExecutor.execute(new Command<String>() {
public String execute(CommandContext commandContext) {
MessageEntity message = new MessageEntity();
commandContext.getJobManager().send(message);
return message.getId();
}
});
}
Aggregations