Search code examples
masstransitsaga

How to discard skipped messages for specific message types in a saga endpoint


I'm working on a project using a saga pattern with MassTransit and I have a scenario where I want to discard skipped messages, but only for specific types of messages. I know that MassTransit provides the DiscardSkippedMessages option, but it applies to all skipped messages.

Is there a way to configure MassTransit to discard skipped messages only for certain message types within a saga endpoint?

I've searched through the MassTransit documentation but I couldn't find a direct solution to my problem.


Solution

  • If you have known message types that are usually handled by the saga but for whatever reason are ending up in the _skipped queue, you should look at ignoring those events in invalid states.

    During(SomeState, Ignore(SkippedEvent));