Nader Kahwaji
Nader Kahwaji

Reputation: 147

Removing cadence workflow and activity timeout

I'm writing a project that uses cadence workflows (cadence client 3.6.2) And I was watching a talk by maxim fateev in 2018 that mentions that cadence workflows are virtual objects and it is better not to think of them as processes that have a start point and an endpoint as they can be always live.

public interface SubscriptionWorkflow {
    @WorkflowMethod
    void manageSubscription(String customerId);
    @SignalMethod
    void cancelSubscription();
    @SignalMethod    
    void updateBillingPeriodChargeAmount(int billingPeriodChargeAmount);
    @QueryMethod    
    String queryCustomerId();
    @QueryMethod        
    int queryBillingPeriodNumber();
    @QueryMethod        
    int queryBillingPeriodChargeAmount();
}

This section of code is from https://cadenceworkflow.io/docs/concepts/workflows/#example

When implementing a workflow it requires to specify the executionStartToCloseTimoutSeconds either by code like this

public interface SubscriptionWorkflow {
    @WorkflowMethod(executionStartToCloseTimoutSeconds = ...)
    void manageSubscription(String customerId);
    ...
}

Or dynamically like

WorkflowOptions options = new WorkflowOptions.Builder().setWorkflowId(...).setTaskList(...)
                .setExecutionStartToCloseTimeout(...).build();
WorkflowStub workflowStub = workflowClient.newUntypedWorkflowStub("SubscriptionWorkflow::manageSubscription",options);
workflowStub.start(...);

And it can also be passed from the cli

docker run --network=host --rm ubercadence/cli:master --do test-domain workflow start --tasklist the_default_task_list --workflow_type SubscriptionWorkflow::manageSubscription --execution_timeout 3600 --input \"id\"

It does seem to be possible to launch a workflow without specifying this timeout and same goes for all the activities inside the workflow.

If I wanted to the workflow in my case to actually live forever is there a way to not add a timeout? same for its activities

Is it considered a bad design to have forever living workflows in general?

Upvotes: 0

Views: 473

Answers (1)

John Del Castillo
John Del Castillo

Reputation: 41

I am assuming your workflow is running forever because it is implementing some sort of loop.

In this case, the workflow will eventually build a history object so large it will no longer be performant, as each loop iteration is persisted and then processed.

Eventually it will hit the configured limit for history events and fail.

Without knowing why you want to run a workflow forever, it's difficult to offer a solution.

You could investigate using Workflow.continueAsNew() which creates a new workflow with the same ID, but starts the history anew and then will avoid hitting any limits.

Upvotes: 2

Related Questions