Conditional Upcasting


Problem: EventA:1.0 has to be upcasted to new version EventA:2.0 and - optionally - to emit also EventB:1.0. The optional event should be emitted (or not) based on the contend of EventA:1.0

Where to put upcasting logic based on upcasted event’s content (let’s say it is JsonNode event) so that I can produce various number of new events?

My note: in IntermediateEventRepresentation upcastPayload. there is an ‘upcatsFunction’ which should be an ideal place but it’s signature forces me to return new event, instead of e.g. Optional type.



Hi Slawek,

I think your solution lies with the EventMultiUpcaster.
This allows you to simply upcast EventA from 1.0 to 2.0, but as you can return a Stream as a result of the upcasting process, you can conditionally add an EventB 1.0 as well.
There’s currently not that much available on samples how to build this sadly…
Best place to look how to do this would be to check out the test cases from the framework itself.

Hoping this helps you further Slawek!


PS. It is important to note that this mailing list will be discontinued as specified in this thread.
The thread also specifies where to look further for help when it comes to Axon as soon as this mailing list is closed.