This feature is not yet available in workflow-py. See our Roadmap for feature parity plans and Changelog for updates.
This example demonstrates how to handle order processing using Upstash Workflow. The workflow will wait for an external system to process an order and resume once it is ‘notified’. See our documentation for more details about events.
Our workflow will be:
Code for notifying the worklfow:
In its first step, we call a method to request processing of the order in the request payload:
You can imagine that this step sends an email to the company responsible for the delivery.
Next, the workflow waits for the order to be processed. It uses the waitForEvent
method to pause execution and listen for the event. A timeout of 10 minutes (600 seconds) is applied to avoid indefinite waiting.
The workflow listens for the event with the ID order-${orderId}
. When the external service notifies the workflow with this ID, the workflow resumes. If no event is received in time, the timeout ensures the workflow doesn’t hang.
Once the workflow resumes, the order data (eventData
) is logged. This step could include updates to the database, inventory adjustments, or other backend operations specific to order processing.
Once the order is processed, the workflow sends a confirmation email to the user.
To notify the workflow that the order has been processed, the external system sends a notification to the workflow with relevant data using the notify
method from the Client
. Alternatively, you can use context.notify
method.
This feature is not yet available in workflow-py. See our Roadmap for feature parity plans and Changelog for updates.
This example demonstrates how to handle order processing using Upstash Workflow. The workflow will wait for an external system to process an order and resume once it is ‘notified’. See our documentation for more details about events.
Our workflow will be:
Code for notifying the worklfow:
In its first step, we call a method to request processing of the order in the request payload:
You can imagine that this step sends an email to the company responsible for the delivery.
Next, the workflow waits for the order to be processed. It uses the waitForEvent
method to pause execution and listen for the event. A timeout of 10 minutes (600 seconds) is applied to avoid indefinite waiting.
The workflow listens for the event with the ID order-${orderId}
. When the external service notifies the workflow with this ID, the workflow resumes. If no event is received in time, the timeout ensures the workflow doesn’t hang.
Once the workflow resumes, the order data (eventData
) is logged. This step could include updates to the database, inventory adjustments, or other backend operations specific to order processing.
Once the order is processed, the workflow sends a confirmation email to the user.
To notify the workflow that the order has been processed, the external system sends a notification to the workflow with relevant data using the notify
method from the Client
. Alternatively, you can use context.notify
method.