1
0
-1

HI,

I'm building a Delivery Service, and need to handle the scenario for retry.

The service has two checkpoints, cpA, and cpB.

When the service is called, if cpA is successful, but cpB has an error, the service will retry.

On the second run of the service cpA will not be executed again, as expected, but variables from cpA are required in cpB, so cpB does not behave properly because of the missing variable.

Is it possible to store the variables from cpA for reuse, or write the service in such a way that each cp is only executed once, but allows for retry?


Thanks

Mark

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      You can use txn properties to store variables to be used in cpB like below

      if (checkpointSvc.doCheckpoint("cpA")) {
      	...
      	// write important varible into txn
      	new TxnUpdater(txn)
      		.setProperty("variableA", "xxx")
      		.update()
      	checkpointSvc.complete("cpA")
      	
      }
      // get updated txn
      txn = new TxnQuery().setTxn(txn).withAll().firstValue()
      if (checkpointSvc.isCompleted("cpA") && checkpointSvc.doCheckpoint("cpB")) {
      	// get variableA from txn
      	String variableA = txn.propertyMap.get("variableA")
      	...
      	checkpointSvc.complete("cpB")
      }
      1. Mark Murray

        Hi Dan,

        thanks for the quick reply.

        That's what I was looking for; I thought there was something similar to the submission.setProperty, but couldn't find it.

        I should be able to make the above work as required.


        Thanks

        Mark

      CommentAdd your comment...