Signaling workflow from activity

Greetings,
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:

COMMAND_TYPE_START_CHILD_WORKFLOW_EXECUTION doesn't match EVENT_TYPE_START_CHILD_WORKFLOW_EXECUTION_INITIATED with EventId=35

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

Thanks!

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