MessageExchangeDAO dao = _dao.getConnection().getMessageExchange(mexId);
if (dao == null) {
// this should not happen....
String msg = "Engine requested non-existent message exchange: " + mexId;
__log.fatal(msg);
throw new BpelEngineException(msg);
}
if (dao.getDirection() != MessageExchangeDAO.DIR_PARTNER_INVOKES_MYROLE) {
// this should not happen....
String msg = "Engine requested my-role request for a partner-role mex: " + mexId;
__log.fatal(msg);
throw new BpelEngineException(msg);
}
MessageExchange.Status status = MessageExchange.Status.valueOf(dao.getStatus());
switch (status) {
case ASYNC:
case REQUEST:
// In the case of pub-sub, the status may already be OK.
case COMPLETED_OK:
MessageDAO request = dao.getRequest();
if (request == null) {
// this also should not happen
String msg = "Engine requested request for message exchange that did not have one: " + mexId;
__log.fatal(msg);
throw new BpelEngineException(msg);
}
return mergeHeaders(request);
default:
// We should not be in any other state when requesting this.
String msg = "Engine requested response while the message exchange " + mexId + " was in the state "
+ status;
__log.fatal(msg);
throw new BpelEngineException(msg);
}
}