diff --git a/dapr-spring/dapr-spring-workflows/src/main/java/io/dapr/spring/workflows/config/DaprWorkflowsConfiguration.java b/dapr-spring/dapr-spring-workflows/src/main/java/io/dapr/spring/workflows/config/DaprWorkflowsConfiguration.java index 88e81906b0..66f4896da1 100644 --- a/dapr-spring/dapr-spring-workflows/src/main/java/io/dapr/spring/workflows/config/DaprWorkflowsConfiguration.java +++ b/dapr-spring/dapr-spring-workflows/src/main/java/io/dapr/spring/workflows/config/DaprWorkflowsConfiguration.java @@ -17,12 +17,14 @@ import io.dapr.workflows.WorkflowActivity; import io.dapr.workflows.runtime.WorkflowRuntime; import io.dapr.workflows.runtime.WorkflowRuntimeBuilder; +import io.micrometer.common.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; import java.util.Map; @@ -54,8 +56,19 @@ private void registerWorkflowsAndActivities(ApplicationContext applicationContex Map workflowActivitiesBeans = applicationContext.getBeansOfType(WorkflowActivity.class); for (WorkflowActivity activity : workflowActivitiesBeans.values()) { - LOGGER.info("Dapr Workflow Activity: '{}' registered", activity.getClass().getName()); + // Get the @Component annotation + Component componentAnnotation = activity.getClass().getAnnotation(Component.class); + + if (componentAnnotation != null) { + var componentValue = componentAnnotation.value(); + if (StringUtils.isNotEmpty(componentValue)) { + LOGGER.info("Dapr Workflow Activity: '{}' with name '{}' registered", activity.getClass().getName(), componentValue); + workflowRuntimeBuilder.registerActivity(componentValue, activity); + return; + } + } + LOGGER.info("Dapr Workflow Activity: '{}' registered", activity.getClass().getName()); workflowRuntimeBuilder.registerActivity(activity); }