use of org.apache.ode.bpel.iapi.MyRoleMessageExchange in project carbon-business-process by wso2.
the class BPELProcessProxy method onAxisServiceInvoke.
public final void onAxisServiceInvoke(final BPELMessageContext bpelMessageContext) throws AxisFault {
boolean success = true;
MyRoleMessageExchange odeMessageExchange = null;
Future responseFuture = null;
// Used to handle exception loosing in when exception occurred
// inside finally block.
Exception cachedException = null;
try {
transactionManager.begin();
if (log.isDebugEnabled()) {
log.debug("Starting Transaction.");
}
odeBpelServer.acquireTransactionLocks();
odeMessageExchange = createMessageExchange(bpelMessageContext.getInMessageContext());
if (odeMessageExchange.getOperation() != null) {
responseFuture = invokeBPELProcessThroughODEMessageExchange(odeMessageExchange, bpelMessageContext);
success = commitODEMessageExchange(odeMessageExchange);
} else {
success = false;
}
} catch (Exception e) {
cachedException = e;
success = false;
handleExceptionAtODEInvocation(e);
} finally {
if (!success) {
releaseODEMessageExchangeAndRollbackTransaction(odeMessageExchange, cachedException, success);
}
}
if (odeMessageExchange.getOperation().getOutput() != null) {
waitForTheResponse(responseFuture, odeMessageExchange);
if (bpelMessageContext.getOutMessageContext() != null) {
if (log.isDebugEnabled()) {
log.debug("Handling response for MEX " + odeMessageExchange);
}
setOutMessageContextSOAPEnvelope(bpelMessageContext);
boolean commit = false;
beginTransactionForTheResponsePath();
try {
// Refreshing the message exchange
odeMessageExchange = (MyRoleMessageExchange) odeBpelServer.getEngine().getMessageExchange(odeMessageExchange.getMessageExchangeId());
onResponse(bpelMessageContext, odeMessageExchange, bpelMessageContext.getOutMessageContext());
// Everything went well. So we can commit the transaction now.
commit = true;
} catch (AxisFault af) {
cachedException = af;
log.warn("MEX produced a fault " + odeMessageExchange, af);
commit = true;
throw af;
} catch (Exception e) {
cachedException = e;
log.error("Error processing response for MEX " + odeMessageExchange, e);
throw new BPELFault("An exception occurred when invoking ODE.", e);
} finally {
try {
odeMessageExchange.release(commit);
} finally {
if (commit) {
commitTransactionForTheResponsePath(cachedException);
} else {
rollbackTransactionForTheResponsePath(cachedException);
}
}
}
}
if (!success) {
throw new BPELFault("Message was either un-routable or timed out!");
}
}
}
use of org.apache.ode.bpel.iapi.MyRoleMessageExchange in project carbon-business-process by wso2.
the class BPELProcessProxy method createMessageExchange.
private MyRoleMessageExchange createMessageExchange(final MessageContext inMessageContext) {
Integer tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
MyRoleMessageExchange messageExchange;
String messageId = new GUID().toString();
messageExchange = odeBpelServer.getEngine().createMessageExchange("" + messageId, serviceName, inMessageContext.getAxisOperation().getName().getLocalPart(), null, tenantId.toString());
if (log.isDebugEnabled()) {
log.debug("ODE routed to portType " + messageExchange.getPortType() + " operation " + messageExchange.getOperation() + " from service " + serviceName);
}
messageExchange.setProperty("isTwoWay", Boolean.toString(inMessageContext.getAxisOperation() instanceof TwoChannelAxisOperation));
return messageExchange;
}
Aggregations