Time Travel

I am currently working in a message-driven microservice project where we do not yet use axon, but will be in the future.

We have a lot of business constraints, that rely on time (waiting x days after a letter has been sent before the next action may happen, …). For testing complex use cases, over the years we came up with the concept of time traveling … so to ensure all relevant time based constraints elapsed, a typical integration test reads like: "go back in time (= set Instant.now) 2 weeks, sent out the letter, go back to “the future” (AKA= today) and evaluate the constraints are met and the next action can be triggered.

When we introduce axon eventsourcing into a world like this … any ideas how we can keep the time travel for testing?
We will have a “mixed” architecture (state based and event based storage), so switching to event-based only and just publish “time elapsed events” that fix the business constraint won’t work.
Can I reply events based on a custom order of events? Can I influence what “now” means for the event publisher? Would you be open to the concept of “CurrentTimeSupplier”, which defaults to “Instant.now()” but can be overwritten programmatically during tests? How do you deal with time based events?

Thanks for your thoughts and comments

Jan

Hi,

Projection side:
“Time travelling” may be done using a “@Timestamp” parameter on an eventhandler.
If you ignore all events to the given “now”, you can get the view right at that Instant.
Since the event handler then thinks it “catched up”, you may need to do replays every time you change the given “now”.

Command side:
This may get complicated, especially when the constraints are build into aggregates triggering events.

I could imagine, that it would be much easier when all the time events would be real events.
This would make it easier to test the actions that are triggered independently from the “scheduling/calendar” engine.

Regards. Johnny.

I vote for the time supplier. It is an easy but very useful concept.