use of org.camunda.bpm.engine.impl.persistence.entity.MessageEntity in project camunda-bpm-platform by camunda.
the class JobExecutorCmdHappyTest method testJobCommandsWithMessage.
public void testJobCommandsWithMessage() {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
String jobId = commandExecutor.execute(new Command<String>() {
public String execute(CommandContext commandContext) {
MessageEntity message = createTweetMessage("i'm coding a test");
commandContext.getJobManager().send(message);
return message.getId();
}
});
AcquiredJobs acquiredJobs = commandExecutor.execute(new AcquireJobsCmd(jobExecutor));
List<List<String>> jobIdsList = acquiredJobs.getJobIdBatches();
assertEquals(1, jobIdsList.size());
List<String> jobIds = jobIdsList.get(0);
List<String> expectedJobIds = new ArrayList<String>();
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.MessageEntity 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.persistence.entity.MessageEntity in project camunda-bpm-platform by camunda.
the class JobEntityTest method testInsertJobWithExceptionMessage.
/**
* Note: This does not test a message with 4-byte Unicode supplementary
* characters for two reasons:
* - MySQL 5.1 does not support 4-byte supplementary characters (support from 5.5.3 onwards)
* - {@link String#length()} counts these characters twice (since they are represented by two
* chars), so essentially the cutoff would be half the actual cutoff for such a string
*/
public void testInsertJobWithExceptionMessage() {
String fittingThreeByteMessage = repeatCharacter("\u9faf", JobEntity.MAX_EXCEPTION_MESSAGE_LENGTH);
JobEntity threeByteJobEntity = new MessageEntity();
threeByteJobEntity.setExceptionMessage(fittingThreeByteMessage);
// should not fail
insertJob(threeByteJobEntity);
deleteJob(threeByteJobEntity);
}
use of org.camunda.bpm.engine.impl.persistence.entity.MessageEntity in project camunda-bpm-platform by camunda.
the class ManagementServiceTest method testSetJobRetriesByDefinitionUnlocksInconsistentJobs.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/ManagementServiceTest.testGetJobExceptionStacktrace.bpmn20.xml" })
public void testSetJobRetriesByDefinitionUnlocksInconsistentJobs() {
// given a job definition
final JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult();
// and an inconsistent job that is never again picked up by a job executor
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Void>() {
@Override
public Void execute(CommandContext commandContext) {
JobManager jobManager = commandContext.getJobManager();
MessageEntity job = new MessageEntity();
job.setJobDefinitionId(jobDefinition.getId());
job.setJobHandlerType("any");
job.setLockOwner("owner");
job.setLockExpirationTime(ClockUtil.getCurrentTime());
job.setRetries(0);
jobManager.send(job);
return null;
}
});
// when the job retries are reset
managementService.setJobRetriesByJobDefinitionId(jobDefinition.getId(), 3);
// then the job can be picked up again
JobEntity job = (JobEntity) managementService.createJobQuery().singleResult();
assertNotNull(job);
assertNull(job.getLockOwner());
assertNull(job.getLockExpirationTime());
assertEquals(3, job.getRetries());
deleteJobAndIncidents(job);
}
use of org.camunda.bpm.engine.impl.persistence.entity.MessageEntity in project camunda-bpm-platform by camunda.
the class JobEntityTest method testJobExceptionMessageCutoff.
public void testJobExceptionMessageCutoff() {
JobEntity threeByteJobEntity = new MessageEntity();
String message = repeatCharacter("a", JobEntity.MAX_EXCEPTION_MESSAGE_LENGTH * 2);
threeByteJobEntity.setExceptionMessage(message);
assertEquals(JobEntity.MAX_EXCEPTION_MESSAGE_LENGTH, threeByteJobEntity.getExceptionMessage().length());
}
Aggregations