if (answerResult.isLive) {
return super.invoke(aid, partnerLink, operation, outgoingMessage, channel);
} else {
PartnerLinkDAO plinkDAO = fetchPartnerLinkDAO(partnerLink);
MessageExchangeDAO mexDao = _dao.getConnection().createMessageExchange(MessageExchangeDAO.DIR_BPEL_INVOKES_PARTNERROLE);
mexDao.setCreateTime(new Date(getCurrentEventDateTime().getTime() + 1));
mexDao.setOperation(operation.getName());
mexDao.setPortType(partnerLink.partnerLink.partnerRolePortType.getQName());
mexDao.setPartnerLinkModelId(partnerLink.partnerLink.getId());
mexDao.setPartnerLink(plinkDAO);
mexDao.setPattern((operation.getOutput() != null ? MessageExchangePattern.REQUEST_RESPONSE : MessageExchangePattern.REQUEST_ONLY).toString());
mexDao.setProcess(_dao.getProcess());
mexDao.setInstance(_dao);
{
MessageDAO request = mexDao.createMessage(new QName("replayer", "replayer"));
request.setData(outgoingMessage);
// try {
// assign(request, answer.getIn());
// } catch (Exception e) {
// throw new FaultException(new QName("replayer", "replayer"), e);
// }
mexDao.setRequest(request);
}
Exchange answer = answerResult.e;
if (mexDao.getPattern().equals(MessageExchangePattern.REQUEST_RESPONSE.toString())) {
if (answer.isSetFault()) {
MessageDAO response = mexDao.createMessage(new QName("replayer", "replayer"));
try {
assign(response, answer.getFault());
} catch (Exception e) {
throw new FaultException(new QName("replayer", "replayer"), e);
}
mexDao.setResponse(response);
mexDao.setFault(answer.getFault().getType());
mexDao.setFaultExplanation(answer.getFault().getExplanation());
mexDao.setStatus(Status.FAULT.toString());
} else if (answer.isSetOut()) {
MessageDAO response = mexDao.createMessage(new QName("replayer", "replayer"));
try {
assign(response, answer.getOut());
} catch (Exception e) {
throw new FaultException(new QName("replayer", "replayer"), e);
}
mexDao.setResponse(response);
mexDao.setStatus(Status.RESPONSE.toString());
} else if (answer.isSetFailure()) {
mexDao.setFaultExplanation(answer.getFailure().getExplanation());
mexDao.setStatus(Status.FAILURE.toString());
} else {
// We don't have output for in-out operation - resulting with
// replayer error to the top
throw new IllegalStateException("I don't have response for invoke " + answer);
}
final String channel2 = channel.export();
final String mexid = mexDao.getMessageExchangeId();
replayerContext.scheduler.scheduleReplayerJob(new Callable() {
public Object call() throws Exception {
__log.debug("executing invoke response " + channel2);
invocationResponse(mexid, channel2);
execute();
return null;
}
}, getCurrentEventDateTime(), this);
} else {
// in only - continuing
mexDao.setStatus(Status.COMPLETED_OK.toString());
}
return mexDao.getMessageExchangeId();
}
}