Comments (1)
Based on the context provided, it seems you are encountering an issue where the type of the workflowInput
variable differs depending on whether MassTransit is enabled or not. This inconsistency is causing trouble when you try to access the input in your INotificationHandler<WorkflowExecuted>
implementation.
In Elsa, inputs to workflows are expected to be dictionaries with string keys and object values, as seen in the examples provided in the context. However, when using different messaging or serialization mechanisms, the actual type of the object that gets deserialized might differ. For instance, with MassTransit, it might be deserialized into a dictionary, while without MassTransit, it might be deserialized into an ExpandoObject
.
To handle this, you could write some conditional logic that checks the type of headersInput
and processes it accordingly. Here's a simplified example of how you might handle both cases:
public async Task HandleAsync(WorkflowExecuted notification, CancellationToken cancellationToken)
{
var workflowInput = notification.WorkflowExecutionContext.Input;
if (workflowInput.TryGetValue("Headers", out var headersInput))
{
if (headersInput is IDictionary<string, object> headersDictionary)
{
// Process headers as dictionary
}
else if (headersInput is ExpandoObject headersExpando)
{
// Convert ExpandoObject to dictionary if necessary and process
var headersDictionary = new Dictionary<string, object>(headersExpando);
// Process headers as dictionary
}
else
{
// Handle unexpected type
}
}
}
This approach ensures that regardless of the underlying type, you can work with the input as a dictionary.
For a more robust solution, you might want to look into custom serialization settings or hooks provided by MassTransit and Elsa to ensure consistent deserialization of workflow inputs.
Since this seems to be a behavior by design or a limitation of the current implementation, you might also want to consider filing an issue on the Elsa GitHub repository to discuss this with the maintainers and possibly improve the documentation or functionality around this area.
This comment was generated by Glime.
from elsa-core.
Related Issues (20)
- [BUG] WorkflowInput does not persist in Bookmark Callback HOT 1
- Next Activity Found But Not Scheduled After Resume [Elsa 3.1.2] HOT 5
- Could you please help me solve this problem as soon as possible? Thank you! HOT 2
- Read event inputs in next activity? HOT 3
- [BUG] Timer Trigger not respecting SingletoneStrategy HOT 4
- Elsa 3.1 oracle migration support HOT 1
- [BUG] Default CRON causes extremely high memory usage until Out of Memory exception HOT 10
- [ENH] Include dropdown when using a nullable enum in an activity input HOT 2
- [BUG] Race Condition in WorkflowDefinitionActivity Causing Execution Failures HOT 1
- [BUG] ResumeWorkflowAsync at ActivityNodeId losing Input values between activities HOT 3
- Unable to Open Workflow Instance View Screen in Customized Elsa UI HOT 4
- Workflow instance viewer activity badges don't update after resuming workflow for a suspended HttpEndpoint activity HOT 1
- [BUG] InvalidOperationException: No service for type 'Elsa.Api.Client.Resources.Package.Contracts.IPackageApi' has been registered. HOT 2
- [DOC] Blocking activities has incorrect code examples HOT 4
- Elsa 3.1.3 Http end point using dispatch workflow not waiting for child workflow completion even though 'Wait for completion' set true HOT 1
- Elsa runs the same workflow multiple times with Azure ServiceBus HOT 2
- Can Chinese be supported HOT 1
- [BUG] FlowJoin Activity Throws NullReferenceException Without Previous Forks
- [PERF] Workflow Graph Loading Enhancement HOT 1
- [PERF] Remove Caching Decorator for Bookmarks to Reduce Service Bus Message Load HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elsa-core.