elsa-core icon indicating copy to clipboard operation
elsa-core copied to clipboard

WorkflowStorageProvider is not honored for Composite Activity

Open jdevillard opened this issue 3 years ago • 2 comments

There is an issue when you use Composite Activity and you don't want to store you input/ouput variable in the StorageProvider (or you want to change the storage provider).

The value from the UI or the default value from the attribute is not honored.

let's consider the example :

public class CompositeTransmit : CompositeActivity
    {

        [ActivityInput(Hint = "Topic Name.", Category = PropertyCategories.Advanced)]

        public string TopicName
        {
            get => GetState<string>();
            set => SetState(value);
        }
        [ActivityInput(Hint = "Content.", Category = PropertyCategories.Advanced, DefaultWorkflowStorageProvider ="Transient")]

        public string Content
        {
            get => GetState<string>();
            set => SetState(value);
        }

        public override void Build(ICompositeActivityBuilder builder)
        {
            builder
                .SendTopicMessage(
                
                setup: (setup)=>
                {

                    setup.Set(x => x.TopicName, () => TopicName);
                    setup.Set(x => x.Message, (context) =>
                    {
                        if(!context.ActivityBlueprint.PropertyStorageProviders.ContainsKey("Message"))
                            context.ActivityBlueprint.PropertyStorageProviders.Add("Message", "Transient");
                        return Content; });
                });
        }
    }

We don't have access in the UI to the configuration of the sub activities of the composite but if we add :

if(!context.ActivityBlueprint.PropertyStorageProviders.ContainsKey("Message"))
                            context.ActivityBlueprint.PropertyStorageProviders.Add("Message", "Transient");

the property is honored and the value is not stored. (not sure if it's the better solution)

But the property Content is always store, this can cause issue and big latency with large message.

we've to be sure that we can consider the WorkflowStorageProvider Settings of the property before saving :

 private async ValueTask SaveWorkflowAsync(WorkflowInstance workflowInstance, CancellationToken cancellationToken)
        {
            _logger.LogTrace("Persisting workflow instance {WorkflowInstanceId}", workflowInstance.Id);

            // Can't prune data - we need to figure out a better way to remove activity output data.
            // Doing it right now causes issues when transferring output data from composite activities.
            //workflowExecutionContext.PruneActivityData();
            
            await _workflowInstanceStore.SaveAsync(workflowInstance, cancellationToken);

            _logger.LogDebug("Committed workflow {WorkflowInstanceId} to storage", workflowInstance.Id);
        }

but I don't know for now if there is some side effet if we work on the workflowInstance at this step.

jdevillard avatar Jun 15 '22 11:06 jdevillard

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 15 '22 11:08 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 14 '22 20:10 stale[bot]