protected void lockJob(JobEntity job) { String lockOwner = jobExecutor.getLockOwner(); job.setLockOwner(lockOwner); int lockTimeInMillis = jobExecutor.getLockTimeInMillis(); GregorianCalendar gregorianCalendar = new GregorianCalendar(); gregorianCalendar.setTime(ClockUtil.getCurrentTime()); gregorianCalendar.add(Calendar.MILLISECOND, lockTimeInMillis); job.setLockExpirationTime(gregorianCalendar.getTime()); }
protected void lockJob(JobEntity job) { String lockOwner = jobExecutor.getLockOwner(); job.setLockOwner(lockOwner); int lockTimeInMillis = jobExecutor.getLockTimeInMillis(); GregorianCalendar gregorianCalendar = new GregorianCalendar(); gregorianCalendar.setTime(ClockUtil.getCurrentTime()); gregorianCalendar.add(Calendar.MILLISECOND, lockTimeInMillis); job.setLockExpirationTime(gregorianCalendar.getTime()); }
@Override public List<JobEntity> execute(CommandContext commandContext) { List<JobEntity> jobs = commandContext.getJobManager().findNextJobsToExecute(new Page(0, 100)); for (JobEntity job : jobs) { job.setLockOwner("test"); } return jobs; } });
@Override public Object execute(CommandContext commandContext) { final JobEntity job = commandContext.getJobManager().findJobById(jobId); job.setLockOwner("someLockOwner"); job.setLockExpirationTime(DateUtils.addHours(ClockUtil.getCurrentTime(), 1)); return null; } });
protected void hintJobExecutor(JobEntity job) { JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor(); if (!jobExecutor.isActive()) { return; } JobExecutorContext jobExecutorContext = Context.getJobExecutorContext(); TransactionListener transactionListener = null; if(!job.isSuspended() && job.isExclusive() && jobExecutorContext != null && jobExecutorContext.isExecutingExclusiveJob() && areInSameProcessInstance(job, jobExecutorContext.getCurrentJob())) { // lock job & add to the queue of the current processor Date currentTime = ClockUtil.getCurrentTime(); job.setLockExpirationTime(new Date(currentTime.getTime() + jobExecutor.getLockTimeInMillis())); job.setLockOwner(jobExecutor.getLockOwner()); transactionListener = new ExclusiveJobAddedNotification(job.getId(), jobExecutorContext); } else { // notify job executor: transactionListener = new MessageAddedNotification(jobExecutor); } Context.getCommandContext() .getTransactionContext() .addTransactionListener(TransactionState.COMMITTED, transactionListener); }
protected void hintJobExecutor(JobEntity job) { JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor(); if (!jobExecutor.isActive()) { return; } JobExecutorContext jobExecutorContext = Context.getJobExecutorContext(); TransactionListener transactionListener = null; if(!job.isSuspended() && job.isExclusive() && jobExecutorContext != null && jobExecutorContext.isExecutingExclusiveJob() && areInSameProcessInstance(job, jobExecutorContext.getCurrentJob())) { // lock job & add to the queue of the current processor Date currentTime = ClockUtil.getCurrentTime(); job.setLockExpirationTime(new Date(currentTime.getTime() + jobExecutor.getLockTimeInMillis())); job.setLockOwner(jobExecutor.getLockOwner()); transactionListener = new ExclusiveJobAddedNotification(job.getId(), jobExecutorContext); } else { // notify job executor: transactionListener = new MessageAddedNotification(jobExecutor); } Context.getCommandContext() .getTransactionContext() .addTransactionListener(TransactionState.COMMITTED, transactionListener); }
public Void execute(CommandContext commandContext) { DbEntityManagerFactory dbEntityManagerFactory = new DbEntityManagerFactory(Context.getProcessEngineConfiguration().getIdGenerator()); DbEntityManager entityManager = dbEntityManagerFactory.openSession(); JobEntity job = entityManager.selectById(JobEntity.class, JOB_ENTITY_ID); job.setLockOwner(lockOwner); entityManager.forceUpdate(job); monitor.sync(); // flush the changed entity and create a lock for the table entityManager.flush(); monitor.sync(); // commit transaction and remove the lock commandContext.getTransactionContext().commit(); return null; }
protected void lockJob(JobEntity job) { String lockOwner = jobExecutor.getLockOwner(); job.setLockOwner(lockOwner); int lockTimeInMillis = jobExecutor.getLockTimeInMillis(); GregorianCalendar gregorianCalendar = new GregorianCalendar(); gregorianCalendar.setTime(ClockUtil.getCurrentTime()); gregorianCalendar.add(Calendar.MILLISECOND, lockTimeInMillis); job.setLockExpirationTime(gregorianCalendar.getTime()); }
@Override public List<JobEntity> execute(CommandContext commandContext) { List<JobEntity> jobs = commandContext.getJobManager().findNextJobsToExecute(new Page(0, 100)); for (JobEntity job : jobs) { job.setLockOwner("test"); } return jobs; } });
@Override public Object execute(CommandContext commandContext) { final JobEntity job = commandContext.getJobManager().findJobById(jobId); job.setLockOwner("someLockOwner"); job.setLockExpirationTime(DateUtils.addHours(ClockUtil.getCurrentTime(), 1)); return null; } });
protected void hintJobExecutor(JobEntity job) { JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor(); if (!jobExecutor.isActive()) { return; } JobExecutorContext jobExecutorContext = Context.getJobExecutorContext(); TransactionListener transactionListener = null; if(!job.isSuspended() && job.isExclusive() && jobExecutorContext != null && jobExecutorContext.isExecutingExclusiveJob() && areInSameProcessInstance(job, jobExecutorContext.getCurrentJob())) { // lock job & add to the queue of the current processor Date currentTime = ClockUtil.getCurrentTime(); job.setLockExpirationTime(new Date(currentTime.getTime() + jobExecutor.getLockTimeInMillis())); job.setLockOwner(jobExecutor.getLockOwner()); transactionListener = new ExclusiveJobAddedNotification(job.getId(), jobExecutorContext); } else { // notify job executor: transactionListener = new MessageAddedNotification(jobExecutor); } Context.getCommandContext() .getTransactionContext() .addTransactionListener(TransactionState.COMMITTED, transactionListener); }
public Void execute(CommandContext commandContext) { DbEntityManagerFactory dbEntityManagerFactory = new DbEntityManagerFactory(Context.getProcessEngineConfiguration().getIdGenerator()); DbEntityManager entityManager = dbEntityManagerFactory.openSession(); JobEntity job = entityManager.selectById(JobEntity.class, JOB_ENTITY_ID); job.setLockOwner(lockOwner); entityManager.forceUpdate(job); monitor.sync(); // flush the changed entity and create a lock for the table entityManager.flush(); monitor.sync(); // commit transaction and remove the lock commandContext.getTransactionContext().commit(); return null; }