MassTransit Saga Configuration For Different Consumer Groups

19 views Asked by At

I've got a situation where I have 4 input topics in Kafka that I'm trying to write a saga to correlate for me.

Topics A, B and C all contain the structurally same data. In all cases, I need to correlate the message that comes in on these three topics with a message that comes in on the 4th topic, D. I know that for every entry in A-C there will be a record in D, but I cannot guarantee that the record will appear on all of these topics.

My plan is to generate 3 sagas ...

  • One that correlates A and D with consumer group AD
  • One that correlates B and D with consumer group BD
  • One that correlates C and D with consumer group CD.

In this way, the message from D will be read three times, but I don't know which of A-C it's going to appear on, so I can't wait for a message that may never arrive.

As the only thing that varies here is the name of the topic A-C and the name of the consumer group to use, I want to write the saga once and associate it with the structurally identical messages.

I've tried to configure the listener in the .UsingKafka() block, but I unclear how I'd do that 3 times.

I've considered that I could create identical (or empty derived) message types for the messages on A-C and three different but identical message types that correspond to the message in D and then declare the saga as a templated type off of these messages, but that seems very hard-coded. I figure there needs to be some way to declare this in configuration. That will require a code change and the creation of a bunch of marker types.

Is there a better way to do this configuration?

0

There are 0 answers