Replies: 1 comment 8 replies
-
You're on the right track here. I will try to create an example workflow that does similar to what you want and get back to you. One thing to remember is that the logging from inside of a workflow can appear confusing. The workflow will call the same However, a single workflow cannot hold an infinite number of activities or signals. As the number grows you will eventually hit a bottleneck. You should plan to create a new workflow to continue things after a while. This also means that you need a way to direct signals to the currently active workflow. You can do this by adding a secondary id that can be shared by multiple workflows. When you need to send a signal, get the list of all workflows with that secondary id and send the signal to the most recently running one. Another option is using tagging such as https://medium.com/@rlmc/extending-laravel-workflow-to-support-spatie-laravel-tags-8b62057dfe3a to track the active workflow. For either of these, you would have a final activity in your workflow that checks if a certain number of signals have been processed, like 100 or so, and then you would create a new workflow of the same type, passing in any previous unprocessed work, and then id/tag or it as the active workflow. Then this activity would return a bool to tell the workflow to stop looping and let the newly created workflow take over. Let me know if that makes sense or if I missed anything. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Hi everyone,
i have the requirement of a long running workflow (~months/years) that receives a signal every day. What is the best way to do this?
I am having some troubles getting things right:
For example this - despite being rather complex - works just fine:
Workflow A:
New messages get added to the "unread" messages collection (responsesToHandle) when the signal arrives - this gets evaluated in execute and triggers the right Activity (yielding activities from signals does not work, right? - at least it did not work for me)
So far so good - tried to apply this template again - did not work - the first yielded activity inside the loop just gets called over and over again - i even tried dropping the Collection and using a simple variable where to store the signals will apply the value sequentially anyway, right?
Workflow B:
This results in something like:
Sometimes when debugging with dd - the loop breaks and execution starts - but i havent figured out when execatly this happens...
Also interest to note is the number of yields somehow depends on the initial response - as the number of debug messages stays the same if i keep the input the same.
What is the best way to achieve "variable" processes - where either signals come in any order and need different handling or where an indefinite number of signals arrive over time?
Thanks for your help!
Beta Was this translation helpful? Give feedback.
All reactions