Schedule workflows that communicate through Temporal signals

I have 5 workflows, lets say workflow A, B, C and D. I want my workflow to communicate with Signal. At the same time I want it to be schedule. What I have done is to using the this documentation/sample-apps/python/signal_your_workflow/signal_external_wf_dacx.py at main · temporalio/documentation · GitHub - sender-receiver design, to send signal from workflow A to some activity, then once completed it will send signal to workflow B, then workflow B will run till complete.

In the link, if you can see, the workflow.get_external_workflow_handle_for required a workflow_id, which is a static workflow id. However, client.create_schedule will create a non-static workflow id, which is workflow id + timestamp.

Hence, how can I get the handle from get_external_workflow_handle_for if the schedule workflow is non-static, which has timestamp? I tested using datetime.now and its unstable, because of the time issue accuracy.

Is this even possible? I just want to use Temporal native scheduler, at the same time to enable workflow to communicate with Signal.

Appreciate your help.

Hi,

However, client.create_schedule will create a non-static workflow id, which is workflow id + timestamp.

yes, we have an issue to improve this Schedules - add option for execution workflowid to be "as-is" (not unique per run) · Issue #4795 · temporalio/temporal · GitHub

for now you will need to use an activity/local activity to get the last workflow id started by the schedule.

        handle = client.get_schedule_handle(
            schedule.id,
        )
        (await handle.describe()).info.running_actions // """Currently running actions."""


Use an activity method to inject the workflow client

is it A a workflow initiated by a schedule as well? if not you could have B signaling A first to register its workflowid

Antonio

Thank you for the response @antonio.perez . To answer your question, yes, workflow A is required to be scheduled, as well as workflow B. I want it to be scheduled with Temporal native method. Hence, both need to be triggered by the scheduler. I will take a look your alternative answer and update if its working.

Thanks for the update,

I guess my approach can only work if A has a static workflowId (initiated by a workflow client, not a scheduler)