/** * 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)); } }); }
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); } }
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); } }
protected void assertNoTransaction() { if (_contexts.isTransacted()) throw new BpelEngineException("Operation must be performed outside of a transaction!"); }
protected void assertTransaction() { if (!_contexts.isTransacted()) throw new BpelEngineException("Operation must be performed in a transaction!"); }
public void setBindingContext(BindingContext bc) { _contexts.bindingContext = bc; }
/** * 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; }
public void setEndpointReferenceContext(EndpointReferenceContext eprContext) throws BpelEngineException { _contexts.eprContext = eprContext; }
public void setScheduler(Scheduler scheduler) throws BpelEngineException { _contexts.scheduler = scheduler; }
public void setMessageExchangeContext(MessageExchangeContext mexContext) throws BpelEngineException { _contexts.mexContext = mexContext; }
public void setTransactionManager(TransactionManager txm) { _contexts.txManager = txm; }