Akka Typed Persistence - is the message format correct?

Hi, I am currently trying Lagom 1.6.4 Akka Typed Persistence and JDBC write side and I was surprised to see in the journal in the message field this event representation:

....Ä.=.H{"idAccount":"2","name":"test2"}.:com.some.package.impl.Account$AccountNameSet....Account|2j$3a5e6bfa-1d2b-45d8-ac97-15f5e40c3914p¬..Ú×]

I was expecting only pure event JSON representation (as it was when I used Lagom 1.5.4 with Lagom Persistence (classic) and Cassandra write side): {"idAccount":"2","name":"test2"}.

Everything works fine, but I wonder if the event serialization works correctly (maybe I have some misconfiguration here). What do you think?

Thank you for any hints
Ales

1 Like

Hi @akahanek,

what you’ve observed is a known issue in Akka Persistence JDBC. The problem is the serialized object is an internal class of Akka Persistence JDBC (a PersistentRepr) which contains the JSON payload instead of serializing the plain JSON payload.

Starting Akka Persistence JDBC 5.0.0 (to be released soon, use 5.0.0-RC1 in the meantime) this should be fixed.

Cheers,

Hi @ignasi35,
thank you very much for your explanation.
Ales

Hi @ignasi35,
now I see that version 5.0.1. of Akka Persistence JDBC plugin is available and I have tried to use it in my Lagom project. I use Lagom 1.6.5.

I have tried this so far:

build.sbt:

val AkkaVersion = "2.6.10"
val SlickVersion = "3.3.3"

lazy val `myproj-impl` = (project in file("myproj-impl"))
...
   .settings(
       libraryDependencies ++= Seq(
        ...
         "com.lightbend.akka" %% "akka-persistence-jdbc" % "5.0.1",
         "com.typesafe.akka" %% "akka-persistence-query" % AkkaVersion,
         "com.typesafe.slick" %% "slick" % SlickVersion,
         "com.typesafe.slick" %% "slick-hikaricp" % SlickVersion
        ...
   )
)

application.conf:

akka {
  persistence {
    journal {
      plugin = "jdbc-journal"
      // Enable the line below to automatically start the journal when the actorsystem is started
      // auto-start-journals = ["jdbc-journal"]
    }
    snapshot-store {
      plugin = "jdbc-snapshot-store"
      // Enable the line below to automatically start the snapshot-store when the actorsystem is started
      // auto-start-snapshot-stores = ["jdbc-snapshot-store"]
    }
  }
}

jdbc-journal {
  slick = ${slick}
}

# the akka-persistence-snapshot-store in use
jdbc-snapshot-store {
  slick = ${slick}
}

# the akka-persistence-query provider in use
jdbc-read-journal {
  slick = ${slick}
}

slick {
  profile = "slick.jdbc.PostgresProfile$"
  db {
    host = "localhost"
    host = ${?DB_HOST}
    url = "jdbc:postgresql://"${slick.db.host}":5432/mydb"
    user = "someuser"
    password = "somepassword"
    driver = "org.postgresql.Driver"
    numThreads = 5
    maxConnections = 5
    minConnections = 1
  }
}

But this does not work.

An error message raised that db.default still needs to be configured and I do not know why. The url, driver, user and password is then configured twice (once in db.default and second in slick).

Then another error raised:

java.lang.NoSuchMethodError: 'com.typesafe.config.Config akka.persistence.jdbc.util.ConfigOps$ConfigOperations$.asConfig$default$2$extension(com.typesafe.config.Config)'

It seems that an older version of typesafe.config.Config is in the classpath.

Please, what is the proper way to configure use of Akka Persistence JDBC Plugin v 5.0.1?

Thank you very much.
Ales

Hi @akahanek,

that seems to be a completely unrelated issue. I’d suggest you created a different discussion.

Cheers,

You are right, I have created a new issue: How to use Akka Persistence JDBC plugin 5.0.1 with Lagom 1.6.5?

Thank you.
Ales