public void execute (ExecutionContext executionContext) throws Exception
{
//validation
if (replyToOriginator != null) {
if (!(Constants.EPR_REPLY.equals(replyToOriginator) || Constants.EPR_FAULT.equals(replyToOriginator))) {
throw new ConfigurationException("EPR type (replyToOriginator) must be \"" + Constants.EPR_REPLY + "\" or \"" + Constants.EPR_FAULT + "\"");
}
} else {
if (null == esbCategoryName)
throw new ConfigurationException(
"Service category (esbCategoryName element) must not be null");
if (null == esbServiceName)
throw new ConfigurationException(
"Service name (esbServiceName element) must not be null");
}
if (millisToWaitForResponse !=null) {
logger.info("millisToWaitForResponse is no longer a valid element, please use a " +
"jBPM timer for this node instead.");
}
//Create the ESB Message
JBpmObjectMapper mapper = new JBpmObjectMapper();
Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, globalProcessScope, executionContext);
//Set the replyTo to the JBpmCallback Service
String esbToBpmVarsXml=null;
if (esbToBpmVars!=null) {
esbToBpmVarsXml = esbToBpmVars.asXML();
}
EPR replyTo = createReplyTo(esbToBpmVarsXml, globalProcessScope, executionContext);
message.getHeader().getCall().setReplyTo(replyTo);
if (exceptionTransition!=null) {
// Set the replyTo to the JBpmCallback Service
EPR faultTo = createFaultTo(esbToBpmVarsXml, globalProcessScope, executionContext);
message.getHeader().getCall().setFaultTo(faultTo);
}
final ContextInstance contextInstance = executionContext.getContextInstance() ;
if (isReplyToOrFaultToSet(contextInstance))
{
setRelatesToMessageId(contextInstance, message);
}
//Sending the message on its way
if (logger.isDebugEnabled()) logger.debug("Created ESB message=" + message);
if (replyToOriginator != null) {
final EPR epr ;
final Object replyToEPR = contextInstance.getVariable(Constants.REPLY_TO);
final Object faultToEPR = contextInstance.getVariable(Constants.FAULT_TO);
if (Constants.EPR_FAULT.equals(replyToOriginator) && (faultToEPR != null)) {
epr = EPRHelper.fromXMLString(faultToEPR.toString()) ;
} else if (replyToEPR != null) {
epr = EPRHelper.fromXMLString(replyToEPR.toString()) ;
} else {
throw new ConfigurationException("No EPR present in process instance") ;
}
if(epr instanceof LogicalEPR) {
final ServiceInvoker invoker = ((LogicalEPR)epr).getServiceInvoker();