Package org.jbpm.db

Examples of org.jbpm.db.JobSession$DeleteJobsSynchronization


  }

  void resumeJobs()
  {
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    JobSession jobSession = (jbpmContext != null ? jbpmContext.getJobSession() : null);
    if (jobSession != null)
    {
      jobSession.resumeJobs(this);
    }
  }
View Full Code Here


        while(true)
        {
            final JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext() ;
            try
            {
                final JobSession jobSession = jbpmContext.getJobSession() ;
                if (jobSession != null)
                {
                    final Set<Long> monitoredJobs = new HashSet<Long>() ;
                    final long now = System.currentTimeMillis() ;
                    do
                    {
                        final Job job = jobSession.getFirstDueJob(RETRY_EXECUTOR, monitoredJobs) ;
                        if ((job == null) || (job.getDueDate().getTime() > now))
                        {
                            break ;
                        }
                        monitoredJobs.add(Long.valueOf(job.getId())) ;
View Full Code Here

   
  protected void unlockOverdueJobs() {
    JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
    try {
      JobSession jobSession = jbpmContext.getJobSession();
     
      Date treshold = new Date(System.currentTimeMillis()-maxLockTime-lockBufferTime);
      List jobsWithOverdueLockTime = jobSession.findJobsWithOverdueLockTime(treshold);
      Iterator iter = jobsWithOverdueLockTime.iterator();
      while (iter.hasNext()) {
        Job job = (Job) iter.next();
        // unlock
        log.debug("unlocking "+job+ " owned by thread "+job.getLockOwner());
        job.setLockOwner(null);
        job.setLockTime(null);
        jobSession.saveJob(job);
      }

    } finally {
      try {
        jbpmContext.close();
View Full Code Here

    Collection jobsToLock = new ArrayList();
    log.debug("acquiring jobs for execution...");
    JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
    try {
      try {
        JobSession jobSession = jbpmContext.getJobSession();
        log.debug("querying for acquirable job...");
        Job job = jobSession.getFirstAcquirableJob(getName());
        if (job!=null) {
          if (job.isExclusive()) {
            log.debug("exclusive acquirable job found ("+job+"). querying for other exclusive jobs to lock them all in one tx...");
            List otherExclusiveJobs = jobSession.findExclusiveJobs(getName(), job.getProcessInstance());
            jobsToLock.addAll(otherExclusiveJobs);
            log.debug("trying to obtain a process-instance exclusive locks for '"+otherExclusiveJobs+"'");
          } else {
            log.debug("trying to obtain a lock for '"+job+"'");
            jobsToLock.add(job);
View Full Code Here


  protected void executeJob(Job job) {
    JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
    try {
      JobSession jobSession = jbpmContext.getJobSession();
      job = jobSession.loadJob(job.getId());

      try {
        log.debug("executing job "+job);
        if (job.execute(jbpmContext)) {
          jobSession.deleteJob(job);
        }

      } catch (Exception e) {
        log.debug("exception while executing '"+job+"'", e);
        StringWriter sw = new StringWriter();
View Full Code Here

  }
  protected Date getNextDueDate() {
    Date nextDueDate = null;
    JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
    try {
      JobSession jobSession = jbpmContext.getJobSession();
      Collection jobIdsToIgnore = jobExecutor.getMonitoredJobIds();
      Job job = jobSession.getFirstDueJob(getName(), jobIdsToIgnore);
      if (job!=null) {
        nextDueDate = job.getDueDate();
        jobExecutor.addMonitoredJobId(getName(), job.getId());
      }
    } finally {
View Full Code Here

    }
  }

  void suspendJobs() {
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    JobSession jobSession = (jbpmContext!=null ? jbpmContext.getJobSession() : null);
    if (jobSession!=null) {
      jobSession.suspendJobs(this);
    }
  }
View Full Code Here

    }
  }

  void resumeJobs() {
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    JobSession jobSession = (jbpmContext!=null ? jbpmContext.getJobSession() : null);
    if (jobSession!=null) {
      jobSession.resumeJobs(this);
    }
  }
View Full Code Here

  }
  public JobSession getJobSession() {
    if (jobSession==null) {
      Session session = getSession();
      if (session!=null) {
        jobSession = new JobSession(session);
      }
    }
    return jobSession;
  }
View Full Code Here

    }
  }

  void suspendJobs() {
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    JobSession jobSession = (jbpmContext!=null ? jbpmContext.getJobSession() : null);
    if (jobSession!=null) {
      jobSession.suspendJobs(this);
    }
  }
View Full Code Here

TOP

Related Classes of org.jbpm.db.JobSession$DeleteJobsSynchronization

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.