Java Code Examples for org.activiti.engine.impl.persistence.entity.JobEntity#setLockExpirationTime()
The following examples show how to use
org.activiti.engine.impl.persistence.entity.JobEntity#setLockExpirationTime() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageBasedJobManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void unacquire(final Job job) { if (job instanceof JobEntity) { JobEntity jobEntity = (JobEntity) job; // When unacquiring, we up the lock time again., so that it isn't cleared by the reset expired thread. jobEntity.setLockExpirationTime(new Date(processEngineConfiguration.getClock().getCurrentTime().getTime() + processEngineConfiguration.getAsyncExecutor().getAsyncJobLockTimeInMillis())); } sendMessage(job); }
Example 2
Source File: DefaultJobManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void unacquire(Job job) { // Deleting the old job and inserting it again with another id, // will avoid that the job is immediately is picked up again (for example // when doing lots of exclusive jobs for the same process instance) if (job instanceof JobEntity) { JobEntity jobEntity = (JobEntity) job; processEngineConfiguration.getJobEntityManager().delete(jobEntity.getId()); JobEntity newJobEntity = processEngineConfiguration.getJobEntityManager().create(); copyJobInfo(newJobEntity, jobEntity); newJobEntity.setId(null); // We want a new id to be assigned to this job newJobEntity.setLockExpirationTime(null); newJobEntity.setLockOwner(null); processEngineConfiguration.getJobEntityManager().insert(newJobEntity); // We're not calling triggerExecutorIfNeeded here after the inser. The unacquire happened // for a reason (eg queue full or exclusive lock failure). No need to try it immediately again, // as the chance of failure will be high. } else { // It could be a v5 job, so simply unlock it. processEngineConfiguration.getJobEntityManager().resetExpiredJob(job.getId()); } }
Example 3
Source File: DefaultJobManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected JobEntity internalCreateLockedAsyncJob(ExecutionEntity execution, boolean exclusive) { JobEntity asyncJob = processEngineConfiguration.getJobEntityManager().create(); fillDefaultAsyncJobInfo(asyncJob, execution, exclusive); GregorianCalendar gregorianCalendar = new GregorianCalendar(); gregorianCalendar.setTime(processEngineConfiguration.getClock().getCurrentTime()); gregorianCalendar.add(Calendar.MILLISECOND, getAsyncExecutor().getAsyncJobLockTimeInMillis()); asyncJob.setLockExpirationTime(gregorianCalendar.getTime()); asyncJob.setLockOwner(getAsyncExecutor().getLockOwner()); return asyncJob; }
Example 4
Source File: DefaultJobManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected JobEntity createExecutableJobFromOtherJob(AbstractJobEntity job) { JobEntity executableJob = processEngineConfiguration.getJobEntityManager().create(); copyJobInfo(executableJob, job); if (isAsyncExecutorActive()) { GregorianCalendar gregorianCalendar = new GregorianCalendar(); gregorianCalendar.setTime(processEngineConfiguration.getClock().getCurrentTime()); gregorianCalendar.add(Calendar.MILLISECOND, getAsyncExecutor().getTimerLockTimeInMillis()); executableJob.setLockExpirationTime(gregorianCalendar.getTime()); executableJob.setLockOwner(getAsyncExecutor().getLockOwner()); } return executableJob; }
Example 5
Source File: AcquireJobsCmd.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void lockJob(CommandContext commandContext, JobEntity job, int lockTimeInMillis) { GregorianCalendar gregorianCalendar = new GregorianCalendar(); gregorianCalendar.setTime(commandContext.getProcessEngineConfiguration().getClock().getCurrentTime()); gregorianCalendar.add(Calendar.MILLISECOND, lockTimeInMillis); job.setLockOwner(asyncExecutor.getLockOwner()); job.setLockExpirationTime(gregorianCalendar.getTime()); }