Exemplo n.º 1
0
  public void onScheduledJob(final JobInfo jobInfo) throws JobProcessorException {
    try {
      final WorkEvent we = new WorkEvent(jobInfo.jobDetail);
      ODEProcess process = _registeredProcesses.get(we.getProcessId());
      if (process == null) {
        // If the process is not active, it means that we should not be
        // doing any work on its behalf, therefore we will reschedule the
        // events for some time in the future (1 minute).

        // 31-05-2010
        // According to the bpel server logic, we won't find a process with matching
        // process id in future for this type of case where we can't find the process at
        // first job invocation. Because all the processes(both hydrated and dehydrated) are there
        // in _registeredProcesses Map. And even we deploy a new version of the process, it's
        // QName will be different because of the versioning.
        // So I am removing scheduling part.
        // TODO: Let's revert the logic if an issue occurred because of this.
        _contexts.execTransaction(
            new Callable<Void>() {
              public Void call() throws Exception {
                _contexts.scheduler.jobCompleted(jobInfo.jobName);
                // Date future = new Date(System.currentTimeMillis() + (60 * 1000));
                // __log.info(__msgs.msgReschedulingJobForInactiveProcess(we.getProcessId(),
                // jobInfo.jobName, future));
                // _contexts.scheduler.schedulePersistedJob(we.getDetail(), future);
                return null;
              }
            });
        return;
      }

      if (we.getType().equals(WorkEvent.Type.INVOKE_CHECK)) {
        if (__log.isDebugEnabled())
          __log.debug("handleWorkEvent: InvokeCheck event for mexid " + we.getMexId());

        PartnerRoleMessageExchange mex =
            (PartnerRoleMessageExchange) getMessageExchange(we.getMexId());
        if (mex.getStatus() == MessageExchange.Status.ASYNC
            || mex.getStatus() == MessageExchange.Status.ACK) {
          String msg =
              "Dangling invocation (mexId=" + we.getMexId() + "), forcing it into a failed state.";
          if (__log.isDebugEnabled()) __log.debug(msg);
          mex.replyWithFailure(MessageExchange.FailureType.COMMUNICATION_ERROR, msg, null);
        }
        return;
      }

      process.handleWorkEvent(jobInfo);
    } catch (Exception ex) {
      throw new JobProcessorException(ex, jobInfo.jobDetail.get("inmem") == null);
    }
  }