extension-kotlin icon indicating copy to clipboard operation
extension-kotlin copied to clipboard

Kotlin Serializer implementation

Open Blackdread opened this issue 5 years ago • 4 comments

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.

Blackdread avatar Jan 01 '20 03:01 Blackdread

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.

smcvb avatar Jan 02 '20 10:01 smcvb

Kotlin serialization has reached a first stable release https://github.com/Kotlin/kotlinx.serialization/releases

sandjelkovic avatar Oct 09 '20 07:10 sandjelkovic

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.

hiddewie avatar May 23 '21 17:05 hiddewie

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.

smcvb avatar Oct 12 '21 09:10 smcvb

I know this is a very old issue, bit this is fixed with https://github.com/AxonFramework/extension-kotlin/pull/338 :)

lion7 avatar Jun 20 '24 11:06 lion7

Very nice, thanks @lion7!

hiddewie avatar Jun 21 '24 16:06 hiddewie