Events
This section describes the additional functionality attached to Axon’s event publication and handling logic.
Event upcasters
A simplified implementation of the Single Event Upcaster is given, which allows for a shorter implementation cycle. Making an upcaster to upcast the CardIssuedEvent
from revision 0
to 1
can be written as follows:
import com.fasterxml.jackson.databind.JsonNode
import org.axonframework.serialization.upcasting.event.SingleEventUpcaster
fun `CardIssuedEvent 0 to 1 Upcaster`(): SingleEventUpcaster =
EventUpcaster.singleEventUpcaster(
eventType = CardIssuedEvent::class,
storageType = JsonNode::class,
revisions = Revisions("0", "1")
) { event ->
// Perform your upcasting process of the CardIssuedEvent here
event
}
class CardIssuedEvent
Alternatively, since Revisions
is essentially a Pair
of String
, it is also possible to use Kotlin’s to
function:
EventUpcaster.singleEventUpcaster(
eventType = CardIssuedEvent::class,
storageType = JsonNode::class,
revisions = "0" to "1"
) { event ->
// Perform your upcasting process of the CardIssuedEvent here
event
}