Signaling workflow from activity

I am trying to signal some external workflow (not the one that triggers activity directly) within the activity. However, I keep getting exceptions like this one:


My question is - is this ok to signal workflow within an activity? If so then how can I bypass this exception?


Yes, you can signal a workflow from an activity, using the WorkflowClient api.

The error typically indicates that you have some non-deterministic code in your workflow. See restrictions here.

Some other thing to avoid in workflow code is looping over unordered collections which can cause non-deterministic behavior, as well as:

  • Don’t use explicit synchronization in your workflow code.
  • You can use non-static fields in your workflow definition without having to worry about isolation issues.
  • For static fields use io.temporal.workflow.WorkflowLocal or io.temporal.workflow.WorkflowThreadLocal depending on your use case You can use Atomic variables, but not really needed.
  • Don’t use synchronized lists, as that will break workflow determinism