Need help understanding tasks for generic workflows #161
|
I went through the docs and understand that a workflow class needs to call task class/service methods from the wrokflow starting method. The thing is each task should be uniquely named with a specific purpose. For e.g., in the hello world example, the HelloWorld workflow has the greet starting method which calls the sayHello and addEnthusiasm methods "statically". All this is really clean for static workflows - workflows which have a defined set of tasks. My use case is this requiring dynamic workflows: users (people who want to automate their work by connecting two or more different apps) can define workflows with mutliple tasks in them from our workflow UI. This workflow and task information is saved in our separate DB. From user perspective, each workflow is different. But technically they are all just one dynamic workflow - a generic workflow that defines a generic task multiple times with different parameters causing it to connect to a different app/service each time. The generic task does just one thing - call a service (technically a web API) as configured by the users. I want to understand would the same task with different parameters be run each time it is called for next task in the workflow? Note that the "next task" in Infinitic terms is not really an Infinitic task but just some data saved in our separate DB. When the workflow starts, it needs to fetch the list of tasks from DB as was defined by the user. Then it needs to run the same generic Infinitic task with different data as fetched from DB. This should look something like this: `interface iGenerictaskService class genericTask extends Task implements iGenerictaskService interface iGenericWorkflowService class GenericWorkflow extends Workflow implements iGenericWorkflow }` As the docs say, once a task has been run and completed, the workflow starts again. But the task taht was already run and whose value is now known does not run again. And that is where my problem lies. Is it possible to have a loop to iterate through the various tasks defined by user and read from DB as data and invoke the same single generic task passing the task data? Would it run the task multiple times as a new task or would it run it only once and then end the workflow? A quick response is much appreciated as it would help me make decision on how should I proceed with my choice of workflow tool. Thanks alot! |
Replies: 1 comment 5 replies
|
Hi, yes this will work - once executed the first task won't be executed again. Internally, a task is defined by its name but also its parameters and its "position" (1st task, 2nd task, etc.). Actually, I worked with a marketing company that does exactly that and uses Infinitic as the workflow engine of their automation service. The way I would do what (in pseudo code): You can do also (more readable to me) - and it lets you use special task such as You are free to use whatever structure in I hope it helps. |
Hi, yes this will work - once executed the first task won't be executed again. Internally, a task is defined by its name but also its parameters and its "position" (1st task, 2nd task, etc.).
Actually, I worked with a marketing company that does exactly that and uses Infinitic as the workflow engine of their automation service.
The way I would do what (in pseudo code):