How to create workflows dynamically in Temporal


Do we need to implement each workflow 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. it is created on-demand.

How to solve this problem in Temporal?

In Temporal you write a single workflow type which interprets your DSL. The interpreter workflow receives the DSL version as an argument and executes it.

Here is the Go DSL sample to give you the idea.

1 Like

Thanks for the reply

Here is the [Go DSL sample] Here is the Go DSL sample to give you the idea.

Do we have Java sample for the same

Unfortunately, there is no Java sample yet.

@maxim it would be a great help if you could add Java DSL Sample as I don’t have knowledge in Go language.

Thanks in advance!!

Yes, we have the Java DSL sample planned.

is there any sample that can be referred for Java DSL or when can we expect it?

Here is one - samples-java/src/main/java/io/temporal/samples/dsl at master · temporalio/samples-java · GitHub

we are planning to further enhance it and also add other types of DSLs in the future, but no timeline atm.

1 Like

Thanks @tihomir :slight_smile: