Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

It is important to make distinction between the state of the instance/element in the flow, and the state of the application involved. A deployed element means that a participant has completed a deploy action, and should not be confused with a deployed application.

In the example there There are scenarios where it make sense when a process is failed, all elements should be repeat fully, by in other scenarios could de different, it depend of the context. Is the participant that has the  Anyway a participant could implement idempotent operations.  

The responsibility to know what have to do.In it needs to be done is delegated to the participant.

When a participant cannot implement idempotent operations, in order to cover the scenario where the process is failed but elements that are in a success state should not be repeat the process, the participant have with failed process with more than one element involved, it has to know what was the previous state.

...

A simple solution from participant side is that they it can use "useState" or "operationalState" to save information related to the deployment process.

Into the participant implementation they it can send the completition of the process by  sendAcElementInfo sendAcElementInfo method.

To support the participant implementation we can add "useState" and "operationalState" into the InstanceElementDto:

...

Below an example with operationalState where the process should not be repeated:

Code Block
languagejava
    @Override
    public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
            throws PfModelException {

        if ("DEPLOYED".equals(instanceElement.operationalState())) {

            // deploy process already done
            intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
                    DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Already Deployed");
            return;
        }
         
        // deployment process
        .......................................
        .......................................
        // end of the deployment process
        
        intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(),
                "", "DEPLOYED", instanceElement.outProperties());

        intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
                DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
    }


    @Override
    public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
            throws PfModelException {

        if ("UNDEPLOYED".equals(instanceElement.operationalState())) {
            // undeploy process already done

            intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
                    DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Already Undeployed");
            return;
        }

        // undeployment process
        .......................................
        .......................................
        // end of the undeployment process        
        
        intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(),
                "", "UNDEPLOYED", instanceElement.outProperties());

        intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
                DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Undeployed");
     }

...