if (!isParticipating(resource)) {
if (log.isDebugEnabled()) { log.debug("skipping not participating resource " + resource); }
continue;
}
Job job = createJob(resource);
Object future = executor.submit(job);
job.setFuture(future);
jobs.add(job);
}
// wait for threads to finish and check results
for (Job job : jobs) {
Object future = job.getFuture();
while (!executor.isDone(future)) {
executor.waitFor(future, 1000L);
}
XAException xaException = job.getXAException();
RuntimeException runtimeException = job.getRuntimeException();
if (xaException != null) {
String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(xaException);
if (log.isDebugEnabled()) { log.debug("error executing " + job + ", errorCode=" + Decoder.decodeXAExceptionErrorCode(xaException) +
(extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails)); }
exceptions.add(xaException);
errorResources.add(job.getResource());
} else if (runtimeException != null) {
if (log.isDebugEnabled()) { log.debug("error executing " + job); }
exceptions.add(runtimeException);
errorResources.add(job.getResource());
}
}
if (log.isDebugEnabled()) { log.debug("phase executed with " + exceptions.size() + " exception(s)"); }
return new JobsExecutionReport(exceptions, errorResources);