dashenswen
dashenswen

Reputation: 600

IncompatibleWorkflowDefinition when canceling the workflow execution

I am testing cancel workflow logic with flow library. The code cancel the workflow within the decider code but it throws IncompatibleWorkflowDefinition

com.amazonaws.services.simpleworkflow.flow.worker.IncompatibleWorkflowDefinition: Unknown DecisionId [type=EXTERNAL_WORKFLOW, id=735]The possible causes are nondeterministic workflow definition code or incompatible change in the workflow defini
tion.

I don't understand why it breaks the logic. Can someone explain why it makes the workflow nondeterministic? Code is like below

@Override
  public void dosomething(final Input input) {
      checkInput();
      cancelCurrentWorkflow();
      asyncMethod();
  }
 private cancelCurrentWorkflow() { contextProvider.getDecisionContext().getWorkflowClient().requestCancelWorkflowExecution(contextProvider.getDecisionContext().getWorkflowContext().getWorkflowExecution());}
 @Asynchronous
 asyncMethod()

Upvotes: 0

Views: 355

Answers (1)

Maxim Fateev
Maxim Fateev

Reputation: 6870

Workflow cancelling itself doesn't make sense. It is usually an operation invoked from the outside using the SWF requestCancelWorkflowExecution API.

If you need to cancel certain part of the workflow code use TryCatchFinally.cancel method.

BTW. Are you aware about Cadence Workflow which is an open source reincarnation of SWF? It has much more developer friendly Java client that doesn't use code generation and AspectJ. It also allows write blocking synchronous code inside the workflow.

Upvotes: 1

Related Questions