Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elsa 3.0.5 - Programmatic workflow with MassTransit MessageReceived activity not starting workflow #4968

Closed
ckeller81 opened this issue Feb 20, 2024 · 9 comments
Assignees
Labels
bug Something isn't working elsa 3 This issue is specific to Elsa 3
Milestone

Comments

@ckeller81
Copy link
Contributor

ckeller81 commented Feb 20, 2024

Summary:
When using Elsa with Elsa.MassTransit and Elsa.MassTransit.RabbitMq and using the MessageReceived activity in a programmatically defined workflow as a start activity / trigger, the workflow is never started.

Used Version
All packages are from NuGet in the version 3.0.5, the example project does not have any other packages referenced.

Example-Code:
https://github.com/ckeller81/elsa-masstransit-test

Reproduce steps:

  • Clone repo
  • start RabbitMq from ./rabbitmq using 'docker-compose up'
  • start project from ./src/ElsaMassTransitTest.csproj using 'dotnet run .\ElsaMassTransitTest.csproj'
  • call http://localhost:5188/ to start a workflow from a queue-message
  • call http://localhost:5188/simple to start a console-log workflow

Expected behaviour:

Actual behaviour:

Workaround
Use elsa without MassTransit, consume the bus-message in a own consumer and start the workflow from this consumer.

Thoughts
After some hours of research, I found out that the queue-message is consumed correctly, but it seems that the workflow-start trigger is either not finding the workflow, or the bookmark. But this was a bit too deep in the package. 😄

Copy link

glime-ai bot commented Feb 20, 2024

Based on the context provided, it seems like you are experiencing an issue where the workflow triggered by a message received from RabbitMQ using Elsa.MassTransit is not starting as expected. This could be due to a variety of reasons, such as misconfiguration of the message handling, incorrect setup of the workflow trigger, or an issue with the Elsa or Elsa.MassTransit packages.

To troubleshoot this issue, you can follow these steps:

  1. Ensure that the RabbitMQ service is running and accessible.
  2. Verify that the message is being published to the correct queue and that the queue is configured correctly in RabbitMQ.
  3. Check that the MessageReceived activity is configured correctly in your workflow to listen to the correct queue and message type.
  4. Ensure that the Elsa services are registered correctly in the Startup.cs or Program.cs file, including the MassTransit integration with Elsa.
  5. Look for any errors or warnings in the application logs that might indicate what is going wrong.
  6. Make sure that the versions of Elsa, Elsa.MassTransit, and any other related packages are compatible with each other.
  7. If possible, create a minimal reproducible example that isolates the issue and share it on the Elsa GitHub issues page or the community forums for further assistance.

If you have already tried these steps and are still facing the issue, it would be helpful to provide more detailed information about your configuration and any error messages you are seeing. Additionally, you can check the Elsa GitHub repository for any open issues or discussions related to your problem, as someone else might have encountered a similar issue.

For further assistance, you can reach out to the Elsa community on GitHub or Gitter, where you can find support from the developers and other users of the Elsa workflow library.

@RyoukoKonpaku
Copy link

From my investigation on making this work on my end, it's because the Type property doesn't match with the incoming payload type which is used on the WorkflowMessageConsumer to dispatch which activity gets triggered, so it never gets executed. Designer created triggers fine as it assigns the type property to the message type.

You can workaround it by overriding that property to match what it does when creating a trigger from the designer.

new MessageReceived
{
    CanStartWorkflow = true,
    Type = ActivityTypeNameHelper.GenerateTypeName(typeof(YourMessageType)),
    MessageType = typeof(YourMessageType),
    Result = new(message)
}

@ckeller81
Copy link
Contributor Author

@RyoukoKonpaku Thank you for the hint!
So it's more of a documentation issue, rather than a bug 😄

Added the Type property, now it is working correctly.

@ckeller81
Copy link
Contributor Author

@sfmskywalker is there any way to contribute to the documentation somehow? 😄

@sfmskywalker
Copy link
Member

@ckeller81 For sure, thank you for asking! To contribute, please follow these steps:

  1. Fork & clone the elsa-documentation repo.
  2. Make the appropriate changes.
  3. Submit a PR.

Notes:

  • V3 documentation lives in the V3 folder.
  • We are migrating the current V3 documentation to the Writerside project which lives in the writerside branch. It's up to you to which version you would like to contribute, but ideally both versions get updated at the same time. Otherwise, we will make sure that your contributions are reflected in the Writerside branch down the road.

Please let me know if there's anything I can help with to get you going. Thanks for considering contributing to the documentation, we really could use some help!

sfmskywalker pushed a commit that referenced this issue Feb 25, 2024
…#4981)

* Added example for a programatic MassTransit triggered workflow (#4968)

* Fixed MassTransitActivities example to include the MassTransitDispatcher (#4968)
@hrb-amason
Copy link

hrb-amason commented May 2, 2024

When following this example I get a serialization issue. Have you experienced this as well?

System.Runtime.Serialization.SerializationException: Failed to serialize message ---> System.NotSupportedException: Serialization and deserialization of 'System.Type' instances is not supported. Path: $.MessageType. ---> System.NotSupportedException: Serialization and deserialization of 'System.Type' instances is not supported.

Seems related to: #5210

@ckeller81
Copy link
Contributor Author

Hey @hrb-amason

The serialization issue you encounter is (as stated in #5210) because the System.Text.Json Serializer does not natively support serializing System.Type.

Mostly because of this issue (despite others), I always change the serializer to Newtonsoft.Json where I need JSON, also when using MassTransit and Elsa.

To change the serializer, you have to add the package MassTransit.Newtonsoft and set the Newtonsoft Serializer inside the RabbitMq configuration part (check the MassTransit documentation and examples for more info).

I would consider this, until #5210 is fixed.

Hope this helps.

@hrb-amason
Copy link

hrb-amason commented May 3, 2024

Hey @ckeller81

Thanks for the response. This was helpful, I was able to replace the serializer for mass transit. Is it possible to point me to sample on how to override the serializer in ELSA?

I have ran into some other issues with the serializer and I haven't found a sample that replaces the serializer with Newtonsoft.

I tried creating my own implementation of https://github.com/elsa-workflows/elsa-core/blob/main/src/modules/Elsa.Common/Contracts/IJsonSerializer.cs but that hasn't worked.

Thanks again!

@sfmskywalker sfmskywalker self-assigned this Jun 10, 2024
@sfmskywalker sfmskywalker added bug Something isn't working elsa 3 This issue is specific to Elsa 3 labels Jun 10, 2024
@sfmskywalker sfmskywalker added this to the Elsa 3.2 milestone Jun 10, 2024
@sfmskywalker
Copy link
Member

Closing this as resolved. Thanks everyone for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working elsa 3 This issue is specific to Elsa 3
Projects
Status: Done
Development

No branches or pull requests

4 participants