Skip to content

Create Custom Workflow Class #1609

@DSpirit

Description

@DSpirit

Ask your question here

I was fiddling around with a custom wrapper using Dapr Workflows to store enhanced activity and event data for better tracking but couldn't achieve that. In a nutshell:
Activities registered in Dapr Workflow never execute when using a custom workflow base class that inherits from Workflow<TInput, TOutput>. The CallActivityAsync hangs indefinitely without calling the activity or throwing an exception.

Is this by design?

Code

Custom Base Workflow Class:

public abstract class MyWorkflow<TInput, TOutput> : Workflow<TInput, TOutput>, IWorkflow
{
    public override async Task<TOutput> RunAsync(WorkflowContext context, TInput input)
    {        
        return await RunCustomAsync(context, input);
    }

    protected abstract Task<TOutput> RunCustomAsync(WorkflowContext context, TInput input);
}

Actual Workflow Implementation:

public class CustomWorkflow : MyWorkflow<RequestModel, object>
{
    protected override async Task<object> RunCustomAsync(WorkflowContext context, RequestModel input)
    {
        // This call just passes through without any action when using the MyWorkflow but works with the regular one
        var result = await context.CallActivityAsync<bool>("MyCustomActivity", input);
        return result;
    }
}

Setup

  • Dapr Version: 1.15.9
  • Framework: .NET 8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions