elsa-workflows / elsa-workflows/elsa-core
[Feature Request] Enable MassTransit Filter Registration
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
## Feature Request
### Problem Overview
**Is your feature request related to a problem? Please describe.**
Currently, Elsa Workflow provides integration features with MassTransit, namely:
- `Elsa.MassTransit`
- `Elsa.MassTransit.AzureServiceBus`
- `Elsa.MassTransit.RabbitMq`
Where the last two are used to configure the underlaying Bus. Each of these Elsa features includes a callback property, such as:
```csharp
public Action? ConfigureServiceBus { get; set; }
```
This allows custom configuration of MassTransit. However, MassTransit's native configuration callback also provides an additional parameter: `IBusRegistrationContext`. Elsa's current implementation does not forward this context, which makes it impossible to register scoped middleware (such as MassTransit scoped filters, see [MassTransit Documentation](https://masstransit.io/documentation/configuration/middleware/scoped).
This missing context severely limits the flexibility in scenarios where scoped services or middleware need to be registered within MassTransit, impacting workflow integrations that require scoped message handling capabilities.
### Proposed Solution
**Describe the solution you'd like**
Extend Elsa's existing MassTransit configuration callback to include `IBusRegistrationContext`. For example, the callback signature could be adjusted as follows:
```csharp
public Action? ConfigureServiceBus { get; set; }
```
This modification would directly pass the MassTransit `IBusRegistrationContext` through Elsa's callback, enabling developers to register scoped middleware and services within their Elsa Workflow integrations seamlessly.
### Alternative Solutions
**Describe alternatives you've considered**
Currently, the only workaround is to directly modify or extend Elsa Workflow features in a custom fork or use extensive reflection and manual wiring, which is cumbersome, error-prone, and difficult to maintain.
Another theoretical alternative is handling scope-related logic externally or duplicating services without using scopes, but this introduces unnecessary complexity and violates best practices.
### Use Cases
**Identify potential use cases**
- Developers integrating scoped middleware into MassTransit via Elsa Workflows.
- Workflow scenarios requiring scoped validation, logging, or custom middleware handling based on the lifecycle of message handling.
- Teams using Elsa Workflow that want full flexibility in configuring MassTransit without losing Elsa's integration benefits.
### Impact of Feature
**Explain the potential impact**
Adding `IBusRegistrationContext` to Elsa’s MassTransit configuration callbacks significantly improves integration capabilities, workflow flexibility, and developer productivity by:
- Enabling direct support for MassTransit scoped middleware within Elsa.
- Reducing complexity and maintenance overhead caused by manual workarounds.
- Ensuring Elsa Workflow integration stays aligned with MassTransit best practices.
### Visuals and Mockups
**Provide any visuals**
_No visuals available at this moment, but the proposed callback signature clearly illustrates the required changes._
### Additional Context
**Add any other context**
Relevant MassTransit documentation on scoped middleware:
- [Scoped Middleware in MassTransit](https://masstransit.io/documentation/configuration/middleware/scoped)
This feature request aligns Elsa Workflow more closely with standard MassTransit conventions and improves developer experience by reducing unnecessary friction in configuration.
Contributor guide
Assessment
This issue has not been assessed yet.