1

Each workflow should be implemented in a separate workflow class?

Is it recommended to implement a generic workflow class where we will call activities and fire timers using the argument which passed to the workflow?

In our use case, we will be creating workflows from UI and it will be created by the end-user. So we cannot define our workflows initially.

Is it recommended approach?

1 Answers1

0

It’s not recommended.

Even though it is still possible if you have to create and register workflow class dynamically using anonymous class. But it will be very difficult to maintain and debug. For example, registering a workflow requires a unique workflow type name, and also it’s required to register back the exact same workflow after worker restarts. Etc.

What you describe is very common use cases in Cadence. And this is also the power of Cadence over other DSL workflow engine. What you need to do is implement a workflow in a way that takes in dynamic input parameters, and decides the behavior on the input. It’s essentially exactly same as what you want to do with dynamic workflow class.

Long Quanzheng
  • 2,076
  • 1
  • 10
  • 22
  • Do we have any java example for this? – Anil Kumble May 19 '21 at 02:33
  • A lots of samples are taking input parameter. You just need to write the workflow logic in a way that behaves based on the input. One example in Golang is DSL workflow: https://github.com/uber-common/cadence-samples/tree/master/cmd/samples/dsl – Long Quanzheng May 19 '21 at 17:50
  • 1
    It would be a great help if you could add a java sample for the same as I don't understand go language. Can I expect it in Java Language @Long – Anil Kumble May 20 '21 at 16:07