I need my events to be stored as json in cassandra (So I can read them with some gui client directly from db).
I’ve followed lagom’s guide https://www.lagomframework.com/documentation/1.4.x/scala/Serialization.html (Enabling JSON Serialization), but events are still stored in something like binary or other format.
Here is what I’ve done:
Created Serializer Registry
object ProjectSerializerRegistry extends JsonSerializerRegistry {
override def serializers: Seq[JsonSerializer[_]] = Seq(
JsonSerializer[ProjectCreated],
)
}
Registered it:
abstract class ProjectsApplication(context: LagomApplicationContext)
extends LagomApplication(context)
with CassandraPersistenceComponents
with LagomKafkaComponents
with AhcWSComponents {
...
// Register the JSON serializer registry
override lazy val jsonSerializerRegistry = ProjectSerializerRegistry
}
Here is the event itself:
case class ProjectCreated(id: String, name: String, createdAt: DateTime) extends ProjectEvent
object ProjectCreated {
implicit val format: OFormat[ProjectCreated] = Json.format[ProjectCreated]
}
After sending command to entity which causes ProjectCreated
event and executing query select event from projects.messages
I expected to see something like this in cassandra:
{
"id": "prj-1",
"name": "Project 1",
"createdAt": "2018-05-04 01:16:00"
}
But instead, I see something like this in event
column:
0x7b226d657373616765223a224869227d
Did I miss something? Or may be it is some compressed or encoded json value?