Exemplo n.º 1
0
  /**
   * Schedule a {@link Runnable} object for execution after the completion of the current
   * transaction.
   *
   * @param runnable
   */
  void scheduleRunnable(final Runnable runnable) {
    assertTransaction();
    _contexts.registerCommitSynchronizer(
        new Runnable() {

          public void run() {
            _exec.submit(new ServerRunnable(runnable));
          }
        });
  }
Exemplo n.º 2
0
  public MessageExchange getMessageExchange(final String mexId) throws BpelEngineException {

    final MessageExchangeDAO inmemdao = getInMemMexDAO(mexId);

    Callable<MessageExchange> loadMex =
        new Callable<MessageExchange>() {

          public MessageExchange call() {
            MessageExchangeDAO mexdao =
                (inmemdao == null)
                    ? mexdao = _contexts.dao.getConnection().getMessageExchange(mexId)
                    : inmemdao;
            if (mexdao == null) return null;

            ProcessDAO pdao = mexdao.getProcess();
            ODEProcess process =
                pdao == null ? null : _registeredProcesses.get(pdao.getProcessId());

            if (process == null) {
              String errmsg = __msgs.msgProcessNotActive(pdao.getProcessId());
              __log.error(errmsg);
              // TODO: Perhaps we should define a checked exception for this
              // condition.
              throw new BpelEngineException(errmsg);
            }

            InvocationStyle istyle = mexdao.getInvocationStyle();
            if (istyle == InvocationStyle.RELIABLE || istyle == InvocationStyle.TRANSACTED)
              assertTransaction();

            switch (mexdao.getDirection()) {
              case MessageExchangeDAO.DIR_BPEL_INVOKES_PARTNERROLE:
                return process.createPartnerRoleMex(mexdao);
              case MessageExchangeDAO.DIR_PARTNER_INVOKES_MYROLE:
                return process.lookupMyRoleMex(mexdao);
              default:
                String errmsg =
                    "BpelEngineImpl: internal error, invalid MexDAO direction: " + mexId;
                __log.fatal(errmsg);
                throw new BpelEngineException(errmsg);
            }
          }
        };

    try {
      if (inmemdao != null || _contexts.isTransacted()) return loadMex.call();
      else return enqueueTransaction(loadMex).get();
    } catch (ContextException e) {
      throw new BpelEngineException(e);
    } catch (Exception e) {
      throw new BpelEngineException(e);
    }
  }
Exemplo n.º 3
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);
    }
  }
Exemplo n.º 4
0
 protected void assertNoTransaction() {
   if (_contexts.isTransacted())
     throw new BpelEngineException("Operation must be performed outside of a transaction!");
 }
Exemplo n.º 5
0
 protected void assertTransaction() {
   if (!_contexts.isTransacted())
     throw new BpelEngineException("Operation must be performed in a transaction!");
 }
Exemplo n.º 6
0
 public void setBindingContext(BindingContext bc) {
   _contexts.bindingContext = bc;
 }
Exemplo n.º 7
0
 /**
  * Set the DAO connection factory. The DAO is used by the BPEL engine to persist information about
  * active processes.
  *
  * @param daoCF {@link BpelDAOConnectionFactory} implementation.
  */
 public void setDaoConnectionFactory(BpelDAOConnectionFactory daoCF) throws BpelEngineException {
   _contexts.dao = daoCF;
 }
Exemplo n.º 8
0
 public void setEndpointReferenceContext(EndpointReferenceContext eprContext)
     throws BpelEngineException {
   _contexts.eprContext = eprContext;
 }
Exemplo n.º 9
0
 public void setScheduler(Scheduler scheduler) throws BpelEngineException {
   _contexts.scheduler = scheduler;
 }
Exemplo n.º 10
0
 public void setMessageExchangeContext(MessageExchangeContext mexContext)
     throws BpelEngineException {
   _contexts.mexContext = mexContext;
 }
Exemplo n.º 11
0
 public void setTransactionManager(TransactionManager txm) {
   _contexts.txManager = txm;
 }