} catch (JMSException e) {
log.debug(e);
}
//1) get the WEEManager instance - required in the same JVM
WeeManager weeManager = WeeManagerImpl.getWeeManagerInstance();
//2) extract the Message's payload
WorkflowInstance wf = null;
UUID uuid = null;
try {
TextMessage msg = null;
if (m instanceof TextMessage) {
msg = (TextMessage) m;
log.debug("WorkflowExecutionEngine: received ObjectMessage at timestamp: " + msg.getJMSTimestamp());
}
// for ObjectMessages: uuid = UUID.fromString(msg.getStringProperty("UUID"));
uuid = UUID.fromString(msg.getText());
/*
* WorkflowInstance object cannot be Serialized due to the org.jboss.ws.core.jaxws.client.ClientProxy
* it contains that cannot be serialized. Therefore a callback to the weeManager for fetching this object
* is performed.
* Not possible: wf = (WorkflowInstance)msg.getObject();
*/
wf = ((WeeManagerImpl)weeManager).getWorkflowInstance(uuid);
//for testing poolsize 1
//Thread.currentThread().sleep(30000);
} catch (Exception e) {
log.error("WorkflowExecutionEngine: error receiving message workflow payload or UUID",e);
if(uuid!=null){
weeManager.notify(uuid,WorkflowExecutionStatus.FAILED);
}
return;
}
//set status for the workflow inISRUNNING
weeManager.notify(uuid,WorkflowExecutionStatus.RUNNING);
//3) executeWorkflow and get WF Result
WorkflowResult ret = wf.initializeExecution();
try {
log.debug("WorkflowExecutionEngine: start executing wf ID: " + wf.getWorkflowID());
//EXECUTES THE WF INSTANCE
List<DigitalObject> payload = wf.getData();
int count = 1;
for(DigitalObject digo : payload){
//process the payload item by item - workflowResult appends individual log items
ret = wf.execute(digo);
count+=1;
int progress = (100/payload.size())*count;
weeManager.notify(uuid, ret, WorkflowExecutionStatus.RUNNING, progress);
}
ret = wf.finalizeExecution();
log.debug("WorkflowExecutionEngine: completed executing wf ID: " + wf.getWorkflowID());
} catch (Exception e) {
log.error("WorkflowExecutionEngine: error running Workflow.execute()",e);
//set WeeManagerstatus 'failed'
weeManager.notify(uuid, WorkflowExecutionStatus.FAILED);
return;
}
//4) call WEEManager.notify to report back results and the status
weeManager.notify(uuid, ret, WorkflowExecutionStatus.COMPLETED);
}