Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support reading akka-persistence snapshots #837

Merged

Conversation

pjfanning
Copy link
Contributor

@pjfanning pjfanning commented Dec 8, 2023

@SakulK would you be able to share a persisted akka snapshot? In base64 format, maybe. It would be useful to have some sort of test.

@pjfanning pjfanning marked this pull request as draft December 8, 2023 14:22
@SakulK
Copy link
Contributor

SakulK commented Dec 8, 2023

Here, along with the code to generate it:

package akka.persistence

import akka.actor.ActorSystem
import akka.serialization.{ SerializationExtension, SerializerWithStringManifest }
import akka.persistence.serialization.Snapshot
import akka.persistence.fsm.PersistentFSM.PersistentFSMSnapshot
import java.util.Base64

object MakeTestSnapshot extends App {
  val system = ActorSystem()
  val serialization = SerializationExtension(system)
  val bytes = serialization.serialize(Snapshot(PersistentFSMSnapshot[String]("test-identifier", "test-data", None)))
  val base64 = Base64.getEncoder.encode(bytes.get)
  println(new String(base64)) // PAAAAAcAAABha2thLnBlcnNpc3RlbmNlLmZzbS5QZXJzaXN0ZW50RlNNJFBlcnNpc3RlbnRGU01TbmFwc2hvdAoPdGVzdC1pZGVudGlmaWVyEg0IFBIJdGVzdC1kYXRh
}

and test deserialization on pekko:

import org.apache.pekko.actor.ActorSystem
import org.apache.pekko.serialization.{ SerializationExtension, SerializerWithStringManifest }
import java.util.Base64
import org.apache.pekko.persistence.serialization.Snapshot

val system = ActorSystem()
val serialization = SerializationExtension(system)
val bytes = Base64.getDecoder.decode("PAAAAAcAAABha2thLnBlcnNpc3RlbmNlLmZzbS5QZXJzaXN0ZW50RlNNJFBlcnNpc3RlbnRGU01TbmFwc2hvdAoPdGVzdC1pZGVudGlmaWVyEg0IFBIJdGVzdC1kYXRh")
val result = serialization.deserialize(bytes, classOf[Snapshot])

@pjfanning pjfanning marked this pull request as ready for review December 9, 2023 10:05
@pjfanning pjfanning changed the title [DRAFT] support reading akka-persistence snapshots support reading akka-persistence snapshots Dec 9, 2023
Copy link
Contributor

@nvollmar nvollmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@pjfanning pjfanning merged commit 15aee50 into apache:1.0.x Dec 9, 2023
17 of 18 checks passed
@pjfanning pjfanning deleted the reading-akka-persistence-snapshots branch December 9, 2023 14:57
@pjfanning pjfanning added this to the 1.0.x milestone Dec 9, 2023
pjfanning added a commit to pjfanning/incubator-pekko that referenced this pull request Dec 9, 2023
* support reading akka-persistence snapshots

* add test

* Update SnapshotSerializerSpec.scala

* Update SnapshotSerializerSpec.scala
pjfanning added a commit that referenced this pull request Dec 11, 2023
* support reading akka-persistence snapshots

* add test

* Update SnapshotSerializerSpec.scala
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants