I'm using mass transit to send messages. I have a project called SharedContracts that contains only dumb messages that are used by other projects. Then I have a Messaging project with consumers, as well as an Application, Infrastructure, and Domain. Now it turns out that I need to use the Saga pattern.
I have a plan, but I don't know how to separate it exactly to keep it "clean". The messages needed for the saga pattern require implementing CorrelatedBy, which is tied to MassTransit, and I don't want the SharedContracts project to have any dependencies. I've tried searching, but I admit that I may be asking the wrong questions or no one addresses this. Unfortunately, ChatGPT didn't offer any advice.
public class ItemCreated : CorrelatedBy<Guid>
{
}
public class ImportDataSaga : ISaga, InitiatedBy<ItemCreated>
{
public Guid CorrelationId { get; set; }
public Task Consume(ConsumeContext<ItemCreated> context)
{
}
}
Thanks a lot.
I've tried googling, I've tried making my own implementation, but I can't think how to do it. The result should be suitable for clean architecture
MassTransit's saga state machines do not required any of those interfaces on messages. However, if you're using the old consumer sagas, they are required. You only need to depend upon MassTransit.Abstractions, which has no other dependencies.