0

I want to implement state machine integrated with Kafka topics. Whenever some message will be produced to a topic, I want state machine to react by changing a state. I have two questions:

  1. Is producing a message on a topic identical with publishing an event?
  2. How to wire things up in a proper way? Some simple code example would be welcome.

1 Answers1

1

Produce is not the same as Publish. You can use Produce to send messages to a topic in Kafka from a state machine:

Initially(
    When(Started)
        .Produce(x => x.Init<KafkaMessage>(new {Text = "text"}))
        .TransitionTo(Active));

There are unit tests that show how it works, I don't believe it is documented yet. It was added in this commit

Chris Patterson
  • 28,659
  • 3
  • 47
  • 59