Hi, Copper Team
I am using copper and get an issue. Need your help.
In my scenario, I get several sequential workflows to run. So I use nested workflow model to organize my implementation.
When using the transient engine to run the main workflow, all the sub workflows can be run correctly in the order as the same order as its corresponding data in TangramInstantiationDatas list.
But when I switch to use persistent engine, only the first sub workflow in TangramInstantiationDatas get executed. And " getEngine().notify(response, ack);” doesn’t notify message to the main workflow wait. Please help how I can fix it.
Thanks!
Below is the sample code.
Main workflow:
public class TangramWorkFlow extends PersistentWorkflow<TangramInstantiationDatas> {
@Override
public void main() throws Interrupt {
for (TangramInstantiationData data : getData().getDatas()) {
correlationId = getEngine().run(data .workflowName, data);
logger.info("Start to wait workflow: " + correlationId);
wait(WaitMode.ALL, 5 * 60 * 60 * 1000, correlationId);
final Response<TangramResponse> response = getAndRemoveResponse(correlationId);
......
}
}
Sub workflow:
public class workflow1 extends AbstractTangramWorkflow<SmartvInstantiationData> {
@Override
public void main() throws Interrupt {
try {
.... //do the logic by getData()
}finally{
TangramResponse tangramResponse = new TangramResponse(success, returnCode);
Response<TangramResponse> response = new Response<TangramResponse>(getId(), tangramResponse, e);
Acknowledge.DefaultAcknowledge ack = new Acknowledge.DefaultAcknowledge();
getEngine().notify(response, ack);
ack.waitForAcknowledge();
}
}
public class workflow2 extends AbstractTangramWorkflow<SmartvInstantiationData> {
@Override
public void main() throws Interrupt {
try {
.... //do the logic by getData()
}finally{
TangramResponse tangramResponse = new TangramResponse(success, returnCode);
Response<TangramResponse> response = new Response<TangramResponse>(getId(), tangramResponse, e);
Acknowledge.DefaultAcknowledge ack = new Acknowledge.DefaultAcknowledge();
getEngine().notify(response, ack);
ack.waitForAcknowledge();
}
TangramInstantiationDatas structure
public class TangramInstantiationDatas implements Serializable {
private static final long serialVersionUID = 8643898572045316654L;
private List<TangramInstantiationData> datas;
public List<TangramInstantiationData> getDatas() {
return datas;
}
public void add(TangramInstantiationData data) {
if (datas == null) {
datas = new LinkedList<>();
}
datas.add(data);
}
private void writeObject(
java.io.ObjectOutputStream out) throws IOException {
out.writeObject(datas);
}
private void readObject(
java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
datas = (LinkedList<TangramInstantiationData>) in.readObject();
}
}
Chao