Search code examples
cadence-workflowtemporal-workflow

Resume Cadence Workflow based on signal without blocking the thread


We want to build a workflow which contains below steps in that order

  1. Execute some synchronous activities.
  2. Trigger an external operation via kafka event.
  3. Listen to the kafka events for the result of the operation.
  4. Execute some other activities based on the result.

Kafka may contain events not related to workflow, so we need a separate workflow to filter the events for that particular workflow.

Using cadence I'm planning to split it into two workflows

  • Workflow1 : 1 -> 2 -> wait for signal -> 4
  • Workflow2 : 3 -> Call workflow1.signal

Is it possible to wait for a signal in workflow1 without actually blocking the thread, so that the thread can process another workflow in the meantime.


Solution

  • I think there is some misunderstanding on how Temporal/Cadence works. There is no requirement to not block a thread for other workflows to be able to make progress. Worker instance will have no problem dealing with such situation.

    So I would recommend to block the thread in the workflow one to wait for the signal as it is the simplest way to solve your business requirements.

    As a side note I don't understand why you need a second workflow. There is no need to have a workflow to filter Kafka events. You can do it directly in a Kafka consumer that signals the first workflow.