Nested copper workflows with persistent engine, wait doesn't get notified

108 views
Skip to first unread message

王超

unread,
Mar 24, 2017, 4:58:58 AM3/24/17
to COPPER Engine
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();
        logger.info("Notify workflow: " + getId());
        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();
        logger.info("Notify workflow: " + getId());
        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

Michael Austermann

unread,
Mar 24, 2017, 6:02:17 AM3/24/17
to copper...@googlegroups.com
The for-loop in TangramWorkFlow.main might be the problem.

 for (TangramInstantiationData data : getData().getDatas())
will create an Iterator and as far as I know, the iterator is not serializable.

Try the following
for (int i=0; i< getData().getDatas().size(); i++) {
  TangramInstantiationData data =  getData().getDatas().get(i);
  ...
}





Von: "王超" <wangch...@gmail.com>
An: "COPPER Engine" <copper...@googlegroups.com>
Gesendet: Freitag, 24. März 2017 09:58:58
Betreff: [COPPER Users] Nested copper workflows with persistent engine, wait doesn't get notified

--
You received this message because you are subscribed to the Google Groups "COPPER Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to copper-engin...@googlegroups.com.
To post to this group, send email to copper...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/copper-engine/e72ee90d-10bd-4f2e-8307-6a6491ceb662%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

王超

unread,
Mar 24, 2017, 11:32:41 AM3/24/17
to COPPER Engine, michael.a...@scoop-software.de
Thanks Michael. Your suggestion works!  Let me do more tests and verify the result. I will post update if get anything.
Reply all
Reply to author
Forward
0 new messages