extension-kotlin
extension-kotlin copied to clipboard
Kotlin Serializer implementation
I have not looked into it yet but I think it can be useful to provide something similar to JacksonSerializer/XStreamSerializer/etc using kotlinx.serialization.
Since I had issues with Jackson with default values and inline class: event changes
Using kotlinx.serialization may be a better solution. If not mistaken, they do not support inline class yet but it will come later for sure.
I will try an implementation later of org.axonframework.serialization.Serializer using kotlinx.serialization.
If you go down this route, @Blackdread, make sure the provided serializer works as expected for every object the framework serializes and deserializes at any point in the code base.
Added, if you could share some benefits of providing a KotlinSerializer
which implements Axon's Serializer
interface, that would be very helpful to understand your stance and drive behind this issue.
Kotlin serialization has reached a first stable release https://github.com/Kotlin/kotlinx.serialization/releases
See #124. I added a basic implementation of a Kotlin serializer that works with the Axon interface. There are test cases to demonstrate how it works.
Ref https://kotlinlang.org/docs/serialization.html with basic overview. Ref https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/serialization-guide.md with serialization guide.
I can give some benefits of the Kotlin Serialization approach:
- Jackson (and most other JVM serializers I know) use reflection which takes a performance hit.
- Kotlin Serialization integrates very easily into the Kotlin language features. For example sealed classes work out of the box, which is not true for Jackson.
- Future enhancements could add other forms of serialized formats, see https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/formats.md
A possible disadvantage is the compiler plugin that is needed to generate the serialization implementation for each class.
I've adjusted the milestone to 0.3.0 instead of 0.2.0.
The intent for this is the desire to release 0.2.0 of the Kotlin extension. We felt we couldn't wait much longer until this release.
I know this is a very old issue, bit this is fixed with https://github.com/AxonFramework/extension-kotlin/pull/338 :)
Very nice, thanks @lion7!