Skip to content

Add Notification Dispatch When Workflow Definitions Are Reloaded#7293

Merged
sfmskywalker merged 2 commits into
release/3.6.0from
bug/7292
Feb 16, 2026
Merged

Add Notification Dispatch When Workflow Definitions Are Reloaded#7293
sfmskywalker merged 2 commits into
release/3.6.0from
bug/7292

Conversation

@sfmskywalker
Copy link
Copy Markdown
Member

@sfmskywalker sfmskywalker commented Feb 13, 2026

Update DefaultRegistriesPopulator to send a WorkflowDefinitionsReloaded notification after repopulating the workflow definition store, allowing other nodes to update their registries accordingly.


Changes

Implementation

  • Update DefaultRegistriesPopulator in
    src/modules/Elsa.Workflows.Runtime/Services/DefaultRegistriesPopulator.cs
  • Inject INotificationSender into the DefaultRegistriesPopulator constructor.
  • Capture the result of
    workflowDefinitionStorePopulator.PopulateStoreAsync(...)
    into a workflowDefinitions variable.
  • Map workflow definitions to ReloadedWorkflowDefinition instances.
  • Create a WorkflowDefinitionsReloaded notification containing the mapped definitions.
  • Send the notification via:
    notificationSender.SendAsync(...)
  • Add using directives for:
    • Elsa.Mediator.Contracts
    • Elsa.Workflows.Runtime.Models
    • Elsa.Workflows.Runtime.Notifications

Impact

Behavior Change

  • Publishes a WorkflowDefinitionsReloaded notification after the workflow definition store is repopulated.
  • Enables replicated nodes or subscribers to react to workflow definition reloads.

Dependencies Affected

  • Requires an INotificationSender implementation to be available via dependency injection.
  • Introduces type usage for:
    • ReloadedWorkflowDefinition
    • WorkflowDefinitionsReloaded

Breaking Changes

  • Modifies the DefaultRegistriesPopulator constructor signature by adding INotificationSender.
  • Requires updates to:
    • DI registrations
    • Any manual instantiation of DefaultRegistriesPopulator

Performance / Side Effects

  • Adds an additional asynchronous send operation (notificationSender.SendAsync) after repopulation.
  • Expected overhead is minimal.
  • Network or mediator errors could surface during notification delivery.

Testing Implications

  • Update unit and integration tests to:
    • Provide or mock INotificationSender
    • Assert that WorkflowDefinitionsReloaded is sent with the expected payload
  • Ensure DI registration tests reflect the new constructor dependency

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Feb 13, 2026

Greptile Overview

Greptile Summary

Enhanced DefaultRegistriesPopulator to broadcast workflow definition reload notifications, enabling distributed nodes to synchronize their activity registries.

  • Captured workflow definitions returned from PopulateStoreAsync in Stage 4
  • Added Stage 5 to convert definitions to ReloadedWorkflowDefinition objects and publish WorkflowDefinitionsReloaded notification
  • Injected INotificationSender dependency to support notification publishing
  • Implementation mirrors the existing pattern in WorkflowDefinitionsReloader for consistency

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation closely follows an established pattern from WorkflowDefinitionsReloader, uses existing notification infrastructure, and adds appropriate distributed system coordination without breaking changes
  • No files require special attention

Important Files Changed

Filename Overview
src/modules/Elsa.Workflows.Runtime/Services/DefaultRegistriesPopulator.cs Added notification support to broadcast workflow definition reloads to other nodes, mirroring the pattern used in WorkflowDefinitionsReloader

Sequence Diagram

sequenceDiagram
    participant Client
    participant DefaultRegistriesPopulator
    participant ActivityRegistryPopulator
    participant WorkflowDefinitionStorePopulator
    participant NotificationSender
    participant RefreshActivityRegistry

    Client->>DefaultRegistriesPopulator: PopulateAsync()
    Note over DefaultRegistriesPopulator: Stage 1
    DefaultRegistriesPopulator->>ActivityRegistryPopulator: PopulateRegistryAsync()
    ActivityRegistryPopulator-->>DefaultRegistriesPopulator: complete
    
    Note over DefaultRegistriesPopulator: Stage 2
    DefaultRegistriesPopulator->>WorkflowDefinitionStorePopulator: PopulateStoreAsync(false)
    WorkflowDefinitionStorePopulator-->>DefaultRegistriesPopulator: complete
    
    Note over DefaultRegistriesPopulator: Stage 3
    DefaultRegistriesPopulator->>ActivityRegistryPopulator: PopulateRegistryAsync()
    ActivityRegistryPopulator-->>DefaultRegistriesPopulator: complete
    
    Note over DefaultRegistriesPopulator: Stage 4
    DefaultRegistriesPopulator->>WorkflowDefinitionStorePopulator: PopulateStoreAsync(true)
    WorkflowDefinitionStorePopulator-->>DefaultRegistriesPopulator: workflowDefinitions
    
    Note over DefaultRegistriesPopulator: Stage 5 (NEW)
    DefaultRegistriesPopulator->>NotificationSender: SendAsync(WorkflowDefinitionsReloaded)
    NotificationSender->>RefreshActivityRegistry: HandleAsync(notification)
    RefreshActivityRegistry-->>NotificationSender: complete
    NotificationSender-->>DefaultRegistriesPopulator: complete
    DefaultRegistriesPopulator-->>Client: complete
Loading

Last reviewed commit: 0a37dcc

@sfmskywalker sfmskywalker changed the title Enhance DefaultRegistriesPopulator: add notification support for workflow definition reloads. Add Notification Dispatch When Workflow Definitions Are Reloaded Feb 13, 2026
Copy link
Copy Markdown
Contributor

@j03y-nxxbz j03y-nxxbz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oke super.

@sfmskywalker sfmskywalker merged commit f5505d6 into release/3.6.0 Feb 16, 2026
6 of 7 checks passed
@sfmskywalker sfmskywalker deleted the bug/7292 branch February 16, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Distributed event to refresh ActivityRegistry cache across replicas when importing workflow definitions

2 participants