I would like to know if I need to do some message persistence configuration in Kafka, in case I want to do the replay at some point, or if when I trigger the replay it pulls it from the EventStore and sends it back to Kafka and resets the tracking tokens, thus ensuring that the processor returns to where I want it. And what happens if I get a new event while I'm processing the old ones, considering that it's quite expensive to keep the events in kafka indefinitely
As you already somewhat pointed out, using Kafka as the message source for Axon Framework will impact what is included in a replay.
Axon Framework itself can deal fine with Kafka only providing a partial history. The replay/reset support as present on the StreamingEventProcessor
does not care in that regard. When resetting, it'll ask the source, which in such a scenario is Kafka, how far back it can go.
Whether it is desirable to only support partial replays is something I cannot answer for you, of course.
If you and the business can decide on a reasonable cut-off from where you know your Projections are no longer replayable, that's fine. Or, perhaps you throw out query models that are 9 months old, for example. I that's the case, you can choose a retention period for Kafka that aligns with that intent.
Anyhow, you will need to decide on the retention period with Kafka. Axon Framework itself does not care about the choice you'd make there.
\> And what happens if I get a new event while I'm processing the old ones, considering that it's quite expensive to keep the events in kafka indefinitely
The new event is appended at the head of the event stream. When replaying, the Event Processor is not at the head of the stream at all. Instead, it is somewhere between the tail and the head, depending on how far the replay has ran for. Hence, the event processor will eventually reach this head and thus process the new event automatically.
Given that the retention period is not set PER event, but for the entire stream, new events adhere to the exact same value as old events.