当前位置: 首页>>代码示例>>Java>>正文


Java JobEntity类代码示例

本文整理汇总了Java中org.activiti.engine.impl.persistence.entity.JobEntity的典型用法代码示例。如果您正苦于以下问题:Java JobEntity类的具体用法?Java JobEntity怎么用?Java JobEntity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JobEntity类属于org.activiti.engine.impl.persistence.entity包,在下文中一共展示了JobEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createJobWithoutExceptionStacktrace

import org.activiti.engine.impl.persistence.entity.JobEntity; //导入依赖的package包/类
private void createJobWithoutExceptionStacktrace() {
    CommandExecutor commandExecutor = (CommandExecutor) processEngineConfiguration.getFlowable5CompatibilityHandler().getRawCommandExecutor();
    commandExecutor.execute(new Command<Void>() {
        public Void execute(CommandContext commandContext) {
            JobEntityManager jobManager = commandContext.getJobEntityManager();

            jobEntity = new JobEntity();
            jobEntity.setJobType(Job.JOB_TYPE_MESSAGE);
            jobEntity.setRevision(1);
            jobEntity.setLockOwner(UUID.randomUUID().toString());
            jobEntity.setRetries(0);
            jobEntity.setExceptionMessage("I'm supposed to fail");

            jobManager.insert(jobEntity);

            assertNotNull(jobEntity.getId());

            return null;

        }
    });

}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:24,代码来源:JobQueryTest.java

示例2: testSetJobRetries

import org.activiti.engine.impl.persistence.entity.JobEntity; //导入依赖的package包/类
@Deployment(resources = { "org/activiti/engine/test/api/mgmt/ManagementServiceTest.testGetJobExceptionStacktrace.bpmn20.xml" })
public void testSetJobRetries() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exceptionInJobExecution");

    // The execution is waiting in the first usertask. This contains a boundary timer event.
    Job timerJob = managementService.createTimerJobQuery()
            .processInstanceId(processInstance.getId())
            .singleResult();

    Date duedate = timerJob.getDuedate();

    assertNotNull("No job found for process instance", timerJob);
    assertEquals(JobEntity.DEFAULT_RETRIES, timerJob.getRetries());

    managementService.setTimerJobRetries(timerJob.getId(), 5);

    timerJob = managementService.createTimerJobQuery()
            .processInstanceId(processInstance.getId())
            .singleResult();
    assertEquals(5, timerJob.getRetries());
    assertEquals(duedate, timerJob.getDuedate());
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:23,代码来源:ManagementServiceTest.java

示例3: testActivityTimeOutEvent

import org.activiti.engine.impl.persistence.entity.JobEntity; //导入依赖的package包/类
@Deployment(resources = "org/activiti/engine/test/api/event/JobEventsTest.testJobEntityEvents.bpmn20.xml")
public void testActivityTimeOutEvent() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testJobEvents");
    Job theJob = managementService.createTimerJobQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(theJob);

    // Force timer to fire
    Calendar tomorrow = Calendar.getInstance();
    tomorrow.add(Calendar.DAY_OF_YEAR, 1);
    processEngineConfiguration.getClock().setCurrentTime(tomorrow.getTime());
    waitForJobExecutorToProcessAllJobsAndExecutableTimerJobs(2000, 100);

    // Check timeout has been dispatched
    assertEquals(1, listener.getEventsReceived().size());
    FlowableEvent activitiEvent = listener.getEventsReceived().get(0);
    assertEquals("ACTIVITY_CANCELLED event expected", FlowableEngineEventType.ACTIVITY_CANCELLED, activitiEvent.getType());
    FlowableActivityCancelledEvent cancelledEvent = (FlowableActivityCancelledEvent) activitiEvent;
    assertTrue("TIMER is the cause of the cancellation", cancelledEvent.getCause() instanceof JobEntity);
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:20,代码来源:ActivityEventsTest.java

示例4: testActivityTimeOutEventInSubProcess

import org.activiti.engine.impl.persistence.entity.JobEntity; //导入依赖的package包/类
@Deployment(resources = "org/activiti/engine/test/bpmn/event/timer/BoundaryTimerEventTest.testTimerOnNestingOfSubprocesses.bpmn20.xml")
public void testActivityTimeOutEventInSubProcess() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerOnNestedSubprocesses");
    Job theJob = managementService.createTimerJobQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(theJob);

    // Force timer to fire
    Calendar timeToFire = Calendar.getInstance();
    timeToFire.add(Calendar.HOUR, 2);
    timeToFire.add(Calendar.SECOND, 5);
    processEngineConfiguration.getClock().setCurrentTime(timeToFire.getTime());
    waitForJobExecutorToProcessAllJobs(2000, 200);

    // Check timeout-events have been dispatched
    assertEquals(3, listener.getEventsReceived().size());
    List<String> eventIdList = new ArrayList<String>();
    for (FlowableEvent event : listener.getEventsReceived()) {
        assertEquals(FlowableEngineEventType.ACTIVITY_CANCELLED, event.getType());
        assertTrue("TIMER is the cause of the cancellation", ((FlowableActivityCancelledEvent) event).getCause() instanceof JobEntity);
        eventIdList.add(((ActivitiActivityEventImpl) event).getActivityId());
    }
    assertTrue(eventIdList.indexOf("innerTask1") >= 0);
    assertTrue(eventIdList.indexOf("innerTask2") >= 0);
    assertTrue(eventIdList.indexOf("innerFork") >= 0);
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:26,代码来源:ActivityEventsTest.java

示例5: testActivityTimeOutEventInCallActivity

import org.activiti.engine.impl.persistence.entity.JobEntity; //导入依赖的package包/类
@Deployment
public void testActivityTimeOutEventInCallActivity() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerOnCallActivity");
    Job theJob = managementService.createTimerJobQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(theJob);

    // Force timer to fire
    Calendar timeToFire = Calendar.getInstance();
    timeToFire.add(Calendar.HOUR, 2);
    timeToFire.add(Calendar.SECOND, 5);
    processEngineConfiguration.getClock().setCurrentTime(timeToFire.getTime());
    waitForJobExecutorToProcessAllJobsAndExecutableTimerJobs(10000, 500);

    // Check timeout-events have been dispatched
    assertEquals(4, listener.getEventsReceived().size());
    List<String> eventIdList = new ArrayList<String>();
    for (FlowableEvent event : listener.getEventsReceived()) {
        assertEquals(FlowableEngineEventType.ACTIVITY_CANCELLED, event.getType());
        assertTrue("TIMER is the cause of the cancellation", ((FlowableActivityCancelledEvent) event).getCause() instanceof JobEntity);
        eventIdList.add(((ActivitiActivityEventImpl) event).getActivityId());
    }
    assertTrue(eventIdList.indexOf("innerTask1") >= 0);
    assertTrue(eventIdList.indexOf("innerTask2") >= 0);
    assertTrue(eventIdList.indexOf("innerFork") >= 0);
    assertTrue(eventIdList.indexOf("callActivity") >= 0);
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:27,代码来源:ActivityEventsTest.java

示例6: testJobCommandsWithMessage

import org.activiti.engine.impl.persistence.entity.JobEntity; //导入依赖的package包/类
public void testJobCommandsWithMessage() {
    ProcessEngineConfigurationImpl activiti5ProcessEngineConfig = (ProcessEngineConfigurationImpl) processEngineConfiguration.getFlowable5CompatibilityHandler().getRawProcessConfiguration();
    CommandExecutor commandExecutor = activiti5ProcessEngineConfig.getCommandExecutor();

    String jobId = commandExecutor.execute(new Command<String>() {

        public String execute(CommandContext commandContext) {
            JobEntity message = createTweetMessage("i'm coding a test");
            commandContext.getJobEntityManager().send(message);
            return message.getId();
        }
    });

    Job job = managementService.createJobQuery().singleResult();
    assertNotNull(job);
    assertEquals(jobId, job.getId());

    assertEquals(0, tweetHandler.getMessages().size());

    activiti5ProcessEngineConfig.getManagementService().executeJob(job.getId());

    assertEquals("i'm coding a test", tweetHandler.getMessages().get(0));
    assertEquals(1, tweetHandler.getMessages().size());
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:25,代码来源:JobExecutorCmdHappyTest.java

示例7: unlockJobIsNeeded

import org.activiti.engine.impl.persistence.entity.JobEntity; //导入依赖的package包/类
protected static void unlockJobIsNeeded(final JobEntity job, final CommandExecutor commandExecutor) {
    try {
        if (job.isExclusive()) {
            commandExecutor.execute(new UnlockExclusiveJobCmd(job));
        }

    } catch (ActivitiOptimisticLockingException optimisticLockingException) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Optimistic locking exception while unlocking the job. If you have multiple async executors running against the same database, " +
                    "this exception means that this thread tried to acquire an exclusive job, which already was changed by another async executor thread." +
                    "This is expected behavior in a clustered environment. " +
                    "You can ignore this message if you indeed have multiple job executor acquisition threads running against the same database. " +
                    "Exception message: {}", optimisticLockingException.getMessage());
        }
    } catch (Throwable t) {
        LOGGER.error("Error while unlocking exclusive job {}", job.getId(), t);
    }
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:19,代码来源:AsyncJobUtil.java

示例8: getJobToDelete

import org.activiti.engine.impl.persistence.entity.JobEntity; //导入依赖的package包/类
protected JobEntity getJobToDelete(CommandContext commandContext) {
    if (jobId == null) {
        throw new ActivitiIllegalArgumentException("jobId is null");
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Deleting job {}", jobId);
    }

    JobEntity job = commandContext.getJobEntityManager().findJobById(jobId);
    if (job == null) {
        throw new ActivitiObjectNotFoundException("No job found with id '" + jobId + "'", Job.class);
    }

    // We need to check if the job was locked, ie acquired by the job acquisition thread
    // This happens if the the job was already acquired, but not yet executed.
    // In that case, we can't allow to delete the job.
    if (job.getLockOwner() != null) {
        throw new ActivitiException("Cannot delete job when the job is being executed. Try again later.");
    }
    return job;
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:22,代码来源:DeleteJobCmd.java

示例9: execute

import org.activiti.engine.impl.persistence.entity.JobEntity; //导入依赖的package包/类
@Override
public Void execute(CommandContext commandContext) {
    JobEntity job = commandContext
            .getJobEntityManager()
            .findJobById(jobId);
    if (job != null) {
        job.setRetries(retries);

        if (commandContext.getEventDispatcher().isEnabled()) {
            commandContext.getEventDispatcher().dispatchEvent(
                    ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_UPDATED, job));
        }
    } else {
        throw new ActivitiObjectNotFoundException("No job found with id '" + jobId + "'.", Job.class);
    }
    return null;
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:18,代码来源:SetJobRetriesCmd.java

示例10: execute

import org.activiti.engine.impl.persistence.entity.JobEntity; //导入依赖的package包/类
@Override
public String execute(CommandContext commandContext) {
    if (jobId == null) {
        throw new ActivitiIllegalArgumentException("jobId is null");
    }

    JobEntity job = commandContext
            .getJobEntityManager()
            .findJobById(jobId);

    if (job == null) {
        throw new ActivitiObjectNotFoundException("No job found with id " + jobId, Job.class);
    }

    return job.getExceptionStacktrace();
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:17,代码来源:GetJobExceptionStacktraceCmd.java

示例11: getJobEntity

import org.activiti.engine.impl.persistence.entity.JobEntity; //导入依赖的package包/类
/**
 * Gets the JobEntity from the given ExecuteAsyncJobCmd.
 *
 * @param executeAsyncJobCmd The ExecuteAsyncJobCmd
 *
 * @return The JobEntity
 */
private JobEntity getJobEntity(ExecuteAsyncJobCmd executeAsyncJobCmd)
{
    /*
     * Unfortunately, ExecuteAsyncJobCmd does not provide an accessible method to get the JobEntity stored within it.
     * We use reflection to force the value out of the object.
     * Also, we cannot simply get the entity and update it. We must retrieve it through the entity manager so it registers in Activiti's persistent object
     * cache. This way when the transaction commits, Activiti is aware of any changes in the JobEntity and persists them correctly.
     */
    try
    {
        Field field = ExecuteAsyncJobCmd.class.getDeclaredField("job");
        ReflectionUtils.makeAccessible(field);
        String jobId = ((JobEntity) ReflectionUtils.getField(field, executeAsyncJobCmd)).getId();

        return Context.getCommandContext().getJobEntityManager().findJobById(jobId);
    }
    catch (NoSuchFieldException | SecurityException e)
    {
        /*
         * This exception should not happen.
         */
        throw new IllegalStateException(e);
    }
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:32,代码来源:HerdCommandInvoker.java

示例12: testExecuteWithExceptionAndGetJobEntityWithNoSuchFieldException

import org.activiti.engine.impl.persistence.entity.JobEntity; //导入依赖的package包/类
@Test
public void testExecuteWithExceptionAndGetJobEntityWithNoSuchFieldException()
{
    // Mock dependencies.
    CommandConfig config = mock(CommandConfig.class);
    JobEntity jobEntity = mock(JobEntity.class);
    ExecuteAsyncJobCmd command = new ExecuteAsyncJobCmd(jobEntity);
    doThrow(NoSuchFieldException.class).when(jobEntity).getId();

    // Try to call the method under test.
    try
    {
        herdCommandInvoker.execute(config, command);
        fail();
    }
    catch (IllegalStateException e)
    {
        assertEquals(NoSuchFieldException.class.getName(), e.getMessage());
    }
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:21,代码来源:HerdCommandInvokerTest.java

示例13: testExecuteWithExceptionAndGetJobEntityWithSecurityException

import org.activiti.engine.impl.persistence.entity.JobEntity; //导入依赖的package包/类
@Test
public void testExecuteWithExceptionAndGetJobEntityWithSecurityException()
{
    // Mock dependencies.
    CommandConfig config = mock(CommandConfig.class);
    JobEntity jobEntity = mock(JobEntity.class);
    ExecuteAsyncJobCmd command = new ExecuteAsyncJobCmd(jobEntity);
    doThrow(SecurityException.class).when(jobEntity).getId();

    // Try to call the method under test.
    try
    {
        herdCommandInvoker.execute(config, command);
        fail();
    }
    catch (IllegalStateException e)
    {
        assertEquals(SecurityException.class.getName(), e.getMessage());
    }
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:21,代码来源:HerdCommandInvokerTest.java

示例14: execute

import org.activiti.engine.impl.persistence.entity.JobEntity; //导入依赖的package包/类
public Object execute(CommandContext commandContext) {
  JobEntity job = Context
    .getCommandContext()
    .getJobManager()
    .findJobById(jobId);
  job.setRetries(job.getRetries() - 1);
  job.setLockOwner(null);
  job.setLockExpirationTime(null);
  
  if(exception != null) {
    job.setExceptionMessage(exception.getMessage());
    job.setExceptionStacktrace(getExceptionStacktrace());
  }
  
  JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor();
  MessageAddedNotification messageAddedNotification = new MessageAddedNotification(jobExecutor);
  TransactionContext transactionContext = commandContext.getTransactionContext();
  transactionContext.addTransactionListener(TransactionState.COMMITTED, messageAddedNotification);
  
  return null;
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:22,代码来源:DecrementJobRetriesCmd.java

示例15: testSetJobRetries

import org.activiti.engine.impl.persistence.entity.JobEntity; //导入依赖的package包/类
@Deployment(resources = {"org/activiti/engine/test/api/mgmt/ManagementServiceTest.testGetJobExceptionStacktrace.bpmn20.xml"})
public void testSetJobRetries() {
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exceptionInJobExecution");

  // The execution is waiting in the first usertask. This contains a boundary
  // timer event.
  Job timerJob = managementService.createJobQuery()
    .processInstanceId(processInstance.getId())
    .singleResult();
  
  assertNotNull("No job found for process instance", timerJob);
  assertEquals(JobEntity.DEFAULT_RETRIES, timerJob.getRetries());

  managementService.setJobRetries(timerJob.getId(), 5);

  timerJob = managementService.createJobQuery()
    .processInstanceId(processInstance.getId())
    .singleResult();
  assertEquals(5, timerJob.getRetries());
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:21,代码来源:ManagementServiceTest.java


注:本文中的org.activiti.engine.impl.persistence.entity.JobEntity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。