Dynamic workflows using springboot autoconfigure

Hi
We are planning to implement dynamic workflow in Springboot. While we have successfully implemented temporal workflows using Springboot, we are stuck at implementing dynamic workflows by using the interface io.temporal.workflow.DynamicWorkflow

Here is the exception we are getting

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'temporalWorkers' defined in class path resource [io/temporal/spring/boot/autoconfigure/RootNamespaceAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.Collection]: Factory method 'workers' threw exception; nested exception is java.lang.IllegalArgumentException: Class doesn't implement any non empty public interface annotated with @WorkflowInterface: my.package.MyWorker
          | 	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
          | 	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638)
          | 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
          | 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
          | 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
          | 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
          | 	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
          | 	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
          | 	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
          | 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
          | 	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
          | 	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
          | 	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
          | 	at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66)
          | 	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)
          | 	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
          | 	at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
          | 	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)
          | 	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)

Here the worker class my.package.MyWorker is implementing io.temporal.workflow.DynamicWorkflow interface

Any help is greatly appreciated.

Thanks

I could get around this issue though it looks hacky.

  • Created an interface that extends DynamicWorkflow interface
  • To that newly created interface, added @WorkflowInterface annotation and @WorkflowMethod to the execute method
@WorkflowInterface
public interface MyDynamicWorkflowInterface extends DynamicWorkflow {
    @Override
    @WorkflowMethod
    Object execute(EncodedValues args);
}

Implementing MyDynamicWorkflowInterface instead of DynamicWorkflow for defining workflow resolved the issue

Please suggest

Hi @maxim
Please let us know if the workaround that I mentioned above is OK or is there any better approach.

Thanks