throw new Scheduler.JobProcessorException(true);
}
}
public void onScheduledJob(Scheduler.JobInfo jobInfo) throws Scheduler.JobProcessorException {
final JobDetails we = jobInfo.jobDetail;
if( __log.isTraceEnabled() ) __log.trace("[JOB] onScheduledJob " + jobInfo + "" + we.getInstanceId());
acquireInstanceLock(we.getInstanceId());
// DONT PUT CODE HERE-need this method real tight in a try/catch block, we need to handle
// all types of failure here, the scheduler is not going to know how to handle our errors,
// ALSO we have to release the lock obtained above (IMPORTANT), lest the whole system come
// to a grinding halt.
BpelProcess process = null;
try {
if (we.getProcessId() != null) {
process = _activeProcesses.get(we.getProcessId());
} else {
ProcessInstanceDAO instance;
if (we.getInMem()) instance = _contexts.inMemDao.getConnection().getInstance(we.getInstanceId());
else instance = _contexts.dao.getConnection().getInstance(we.getInstanceId());
if (instance == null) {
__log.debug(__msgs.msgScheduledJobReferencesUnknownInstance(we.getInstanceId()));
// nothing we can do, this instance is not in the database, it will always fail, not
// exactly an error since can occur in normal course of events.
return;
}
ProcessDAO processDao = instance.getProcess();
process = _activeProcesses.get(processDao.getProcessId());
}
if (process == null) {
// The process is not active, there's nothing we can do with this job
__log.debug("Process " + we.getProcessId() + " can't be found, job abandoned.");
return;
}
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(process._classLoader);
if (we.getType().equals(JobType.INVOKE_CHECK)) {
if (__log.isDebugEnabled()) __log.debug("handleJobDetails: InvokeCheck event for mexid " + we.getMexId());
sendPartnerRoleFailure(we, MessageExchange.FailureType.COMMUNICATION_ERROR);
return;
} else if (we.getType().equals(JobType.INVOKE_INTERNAL)) {
if (__log.isDebugEnabled()) __log.debug("handleJobDetails: InvokeInternal event for mexid " + we.getMexId());
setMessageExchangeProcess(we.getMexId(), process.getProcessDAO());
MyRoleMessageExchangeImpl mex = (MyRoleMessageExchangeImpl) getMessageExchange(we.getMexId());
if (!process.processInterceptors(mex, InterceptorInvoker.__onJobScheduled)) {
boolean isTwoWay = Boolean.valueOf(mex.getProperty("isTwoWay"));
if (isTwoWay) {
String causeCodeValue = mex.getProperty("causeCode");
mex.getDAO().setProcess(process.getProcessDAO());
sendMyRoleFault(process, we, causeCodeValue != null ?
Integer.valueOf(causeCodeValue) : InvalidProcessException.DEFAULT_CAUSE_CODE);
return;
} else {
throw new Scheduler.JobProcessorException(checkRetry(we));
}
}
}
if (we.getType() == JobType.INVOKE_INTERNAL || we.getType() == JobType.MEX_MATCHER) {
List<BpelProcess> processes = getAllProcesses(we.getProcessId());
boolean routed = false;
jobInfo.jobDetail.detailsExt.put("enqueue", false);
for(BpelProcess proc : processes) {
routed = routed || proc.handleJobDetails(jobInfo.jobDetail);
}
if(!routed && we.getType() == JobType.INVOKE_INTERNAL) {
jobInfo.jobDetail.detailsExt.put("enqueue", true);
process.handleJobDetails(jobInfo.jobDetail);
}
}
else {