• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java JobExecutor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: schedule

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
public void schedule(TimerEntity timer) {
  Date duedate = timer.getDuedate();
  if (duedate==null) {
    throw new ActivitiException("duedate is null");
  }
  
  CommandContext commandContext = Context.getCommandContext();
  
  commandContext
    .getDbSqlSession()
    .insert(timer);
  
  // Check if this timer fires before the next time the job executor will check for new timers to fire.
  // This is highly unlikely because normally waitTimeInMillis is 5000 (5 seconds)
  // and timers are usually set further in the future
  
  JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor();
  int waitTimeInMillis = jobExecutor.getWaitTimeInMillis();
  if (duedate.getTime() < (ClockUtil.getCurrentTime().getTime()+waitTimeInMillis)) {
    // then notify the job executor.
    commandContext
      .getTransactionContext()
      .addTransactionListener(TransactionState.COMMITTED, new MessageAddedNotification(jobExecutor));
  }
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:26,代码来源:JobManager.java


示例2: waitForJobExecutorToProcessAllJobs

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
public static void waitForJobExecutorToProcessAllJobs(ProcessEngineConfigurationImpl processEngineConfiguration, long maxMillisToWait, long intervalMillis) {
  JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
  jobExecutor.start();

  try {
    Timer timer = new Timer();
    InteruptTask task = new InteruptTask(Thread.currentThread());
    timer.schedule(task, maxMillisToWait);
    boolean areJobsAvailable = true;
    try {
      while (areJobsAvailable && !task.isTimeLimitExceeded()) {
        Thread.sleep(intervalMillis);
        areJobsAvailable = areJobsAvailable(processEngineConfiguration);
      }
    } catch (InterruptedException e) {
    } finally {
      timer.cancel();
    }
    if (areJobsAvailable) {
      throw new ActivitiException("time limit of " + maxMillisToWait + " was exceeded");
    }

  } finally {
    jobExecutor.shutdown();
  }
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:27,代码来源:TestHelper.java


示例3: waitForJobExecutorToProcessAllJobs

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
public void waitForJobExecutorToProcessAllJobs(long maxMillisToWait, long intervalMillis) {
  JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
  jobExecutor.start();

  try {
    Timer timer = new Timer();
    InteruptTask task = new InteruptTask(Thread.currentThread());
    timer.schedule(task, maxMillisToWait);
    boolean areJobsAvailable = true;
    try {
      while (areJobsAvailable && !task.isTimeLimitExceeded()) {
        Thread.sleep(intervalMillis);
        areJobsAvailable = areJobsAvailable();
      }
    } catch (InterruptedException e) {
    } finally {
      timer.cancel();
    }
    if (areJobsAvailable) {
      throw new ActivitiException("time limit of " + maxMillisToWait + " was exceeded");
    }

  } finally {
    jobExecutor.shutdown();
  }
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:27,代码来源:AbstractActivitiTestCase.java


示例4: execute

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的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


示例5: schedule

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
public void schedule(TimerEntity timer) {
  Date duedate = timer.getDuedate();
  if (duedate==null) {
    throw new ActivitiException("duedate is null");
  }
  
  CommandContext commandContext = Context.getCommandContext();
  
  commandContext
    .getDbSqlSession()
    .insert(timer);
  
  // Check if this timer fires before the next time the job executor will check for new timers to fire.
  // This is highly unlikely because normally waitTimeInMillis is 5000 (5 seconds)
  // and timers are usually set further in the future
  
  JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor();
  int waitTimeInMillis = jobExecutor.getWaitTimeInMillis();
  if (duedate.getTime() < (ClockUtil.getCurrentTime().getTime()+waitTimeInMillis)) {
    hintJobExecutor(timer);
  }
}
 
开发者ID:iotsap,项目名称:FiWare-Template-Handler,代码行数:23,代码来源:JobManager.java


示例6: schedule

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
public void schedule(TimerEntity timer) {
  Date duedate = timer.getDuedate();
  if (duedate==null) {
    throw new ActivitiIllegalArgumentException("duedate is null");
  }

  timer.insert();
  
  // Check if this timer fires before the next time the job executor will check for new timers to fire.
  // This is highly unlikely because normally waitTimeInMillis is 5000 (5 seconds)
  // and timers are usually set further in the future
  
  JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor();
  int waitTimeInMillis = jobExecutor.getWaitTimeInMillis();
  if (duedate.getTime() < (ClockUtil.getCurrentTime().getTime()+waitTimeInMillis)) {
    hintJobExecutor(timer);
  }
}
 
开发者ID:springvelocity,项目名称:xbpm5,代码行数:19,代码来源:JobEntityManager.java


示例7: execute

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
public Object execute(CommandContext commandContext) {
  JobEntity job = Context
    .getCommandContext()
    .getJobEntityManager()
    .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:springvelocity,项目名称:xbpm5,代码行数:22,代码来源:DecrementJobRetriesCmd.java


示例8: send

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
public void send(MessageEntity message) {
  CommandContext commandContext = Context.getCommandContext();
  
  commandContext
    .getDbSqlSession()
    .insert(message);
  
  
  JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor();
  commandContext
    .getTransactionContext()
    .addTransactionListener(TransactionState.COMMITTED, new MessageAddedNotification(jobExecutor));
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:14,代码来源:JobManager.java


示例9: run

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
public void run() {
  try {
    JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
    processEngineConfiguration
      .getCommandExecutorTxRequired()
      .execute(new ControlledCommand(activeThread, new AcquireJobsCmd(jobExecutor)));

  } catch (ActivitiOptimisticLockingException e) {
    this.exception = e;
  }
  log.fine(getName()+" ends");
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:13,代码来源:CompetingJobAcquisitionTest.java


示例10: testJobCommandsWithMessage

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
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.getJobIdsList();
  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());

  commandExecutor.execute(new ExecuteJobsCmd(jobId));

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


示例11: testJobCommandsWithTimer

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
public void testJobCommandsWithTimer() {
  // clock gets automatically reset in LogTestCase.runTest
  ClockUtil.setCurrentTime(new Date(SOME_TIME));

  CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
  JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();

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

    public String execute(CommandContext commandContext) {
      TimerEntity timer = createTweetTimer("i'm coding a test", new Date(SOME_TIME + (10 * SECOND)));
      commandContext.getJobManager().schedule(timer);
      return timer.getId();
    }
  });

  AcquiredJobs acquiredJobs = commandExecutor.execute(new AcquireJobsCmd(jobExecutor));
  List<List<String>> jobIdsList = acquiredJobs.getJobIdsList();
  assertEquals(0, jobIdsList.size());

  List<String> expectedJobIds = new ArrayList<String>();

  ClockUtil.setCurrentTime(new Date(SOME_TIME + (20 * SECOND)));

  acquiredJobs = commandExecutor.execute(new AcquireJobsCmd(jobExecutor));
  jobIdsList = acquiredJobs.getJobIdsList();
  assertEquals(1, jobIdsList.size());

  List<String> jobIds = jobIdsList.get(0);

  expectedJobIds.add(jobId);
  assertEquals(expectedJobIds, new ArrayList<String>(jobIds));

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

  commandExecutor.execute(new ExecuteJobsCmd(jobId));

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


示例12: moveByMinutes

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
private void moveByMinutes(int minutes) throws Exception {
  ClockUtil.setCurrentTime(new Date(ClockUtil.getCurrentTime().getTime() + ((minutes * 60 * 1000) + 5000)));
  JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
  jobExecutor.start();
  Thread.sleep(1000);

  jobExecutor.shutdown();
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:9,代码来源:StartTimerEventTest.java


示例13: moveByHours

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
private void moveByHours(int hours) throws Exception {
  ClockUtil.setCurrentTime(new Date(ClockUtil.getCurrentTime().getTime() + ((hours * 60 * 1000 * 60) + 5000)));
  JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
  jobExecutor.start();
  Thread.sleep(1000);
  jobExecutor.shutdown();
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:8,代码来源:BoundaryTimerNonInterruptingEventTest.java


示例14: testJobCommandsWithMessage

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
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());

  commandExecutor.execute(new ExecuteJobsCmd(jobId));

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


示例15: testJobCommandsWithTimer

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
public void testJobCommandsWithTimer() {
  // clock gets automatically reset in LogTestCase.runTest
  ClockUtil.setCurrentTime(new Date(SOME_TIME));

  CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
  JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();

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

    public String execute(CommandContext commandContext) {
      TimerEntity timer = createTweetTimer("i'm coding a test", new Date(SOME_TIME + (10 * SECOND)));
      commandContext.getJobManager().schedule(timer);
      return timer.getId();
    }
  });

  AcquiredJobs acquiredJobs = commandExecutor.execute(new AcquireJobsCmd(jobExecutor));
  List<List<String>> jobIdsList = acquiredJobs.getJobIdBatches();
  assertEquals(0, jobIdsList.size());

  List<String> expectedJobIds = new ArrayList<String>();

  ClockUtil.setCurrentTime(new Date(SOME_TIME + (20 * SECOND)));

  acquiredJobs = commandExecutor.execute(new AcquireJobsCmd(jobExecutor));
  jobIdsList = acquiredJobs.getJobIdBatches();
  assertEquals(1, jobIdsList.size());

  List<String> jobIds = jobIdsList.get(0);

  expectedJobIds.add(jobId);
  assertEquals(expectedJobIds, new ArrayList<String>(jobIds));

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

  commandExecutor.execute(new ExecuteJobsCmd(jobId));

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


示例16: waitForJobExecutorToProcessAllJobs

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
public void waitForJobExecutorToProcessAllJobs(long maxMillisToWait, long intervalMillis) {
  JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
  jobExecutor.start();

  try {
    Timer timer = new Timer();
    InteruptTask task = new InteruptTask(Thread.currentThread());
    timer.schedule(task, maxMillisToWait);
    boolean areJobsAvailable = true;
    try {
      while (areJobsAvailable && !task.isTimeLimitExceeded()) {
        Thread.sleep(intervalMillis);
        try {
          areJobsAvailable = areJobsAvailable();
        } catch(Throwable t) {
          // Ignore, possible that exception occurs due to locking/updating of table on MSSQL when
          // isolation level doesn't allow READ of the table
        }
      }
    } catch (InterruptedException e) {
      // ignore
    } finally {
      timer.cancel();
    }
    if (areJobsAvailable) {
      throw new ActivitiException("time limit of " + maxMillisToWait + " was exceeded");
    }

  } finally {
    jobExecutor.shutdown();
  }
}
 
开发者ID:springvelocity,项目名称:xbpm5,代码行数:33,代码来源:AbstractActivitiTestCase.java


示例17: run

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
public void run() {
  try {
    JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
    processEngineConfiguration
      .getCommandExecutor()
      .execute(new ControlledCommand(activeThread, new AcquireJobsCmd(jobExecutor)));

  } catch (ActivitiOptimisticLockingException e) {
    this.exception = e;
  }
  log.debug("{} ends", getName());
}
 
开发者ID:springvelocity,项目名称:xbpm5,代码行数:13,代码来源:CompetingJobAcquisitionTest.java


示例18: testJobCommandsWithMessage

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
public void testJobCommandsWithMessage() {
  CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
  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.getJobEntityManager().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());

  commandExecutor.execute(new ExecuteJobsCmd(jobId));

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


示例19: testJobCommandsWithTimer

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
public void testJobCommandsWithTimer() {
  // clock gets automatically reset in LogTestCase.runTest
  ClockUtil.setCurrentTime(new Date(SOME_TIME));

  CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
  JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();

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

    public String execute(CommandContext commandContext) {
      TimerEntity timer = createTweetTimer("i'm coding a test", new Date(SOME_TIME + (10 * SECOND)));
      commandContext.getJobEntityManager().schedule(timer);
      return timer.getId();
    }
  });

  AcquiredJobs acquiredJobs = commandExecutor.execute(new AcquireJobsCmd(jobExecutor));
  List<List<String>> jobIdsList = acquiredJobs.getJobIdBatches();
  assertEquals(0, jobIdsList.size());

  List<String> expectedJobIds = new ArrayList<String>();

  ClockUtil.setCurrentTime(new Date(SOME_TIME + (20 * SECOND)));

  acquiredJobs = commandExecutor.execute(new AcquireJobsCmd(jobExecutor));
  jobIdsList = acquiredJobs.getJobIdBatches();
  assertEquals(1, jobIdsList.size());

  List<String> jobIds = jobIdsList.get(0);

  expectedJobIds.add(jobId);
  assertEquals(expectedJobIds, new ArrayList<String>(jobIds));

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

  commandExecutor.execute(new ExecuteJobsCmd(jobId));

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


示例20: getJobExecutor

import org.activiti.engine.impl.jobexecutor.JobExecutor; //导入依赖的package包/类
public JobExecutor getJobExecutor() {
  return jobExecutor;
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:4,代码来源:ProcessEngineConfigurationImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EMGroupManager类代码示例发布时间:2022-05-23
下一篇:
Java DatabaseNotFoundException类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap