When using akka-persistence-dynamodb, akka is not finding the proper avro serialzer

132 views
Skip to first unread message

Asif Fayyaz

unread,
Feb 21, 2017, 9:07:39 AM2/21/17
to Akka User List
We are using akka-persistence-dynamodb plugin for akka persistance and using avro for our data serialization. We loaded the serializer along with serializer bindings via configuration and we can see that configuration does load the proper serializer for the required object. However, When calling "Persist" with the given object, akka is still trying to use JavaSerializer.

Here is the error that we are getting. 

[error] a.p.d.j.DynamoDBJournal - swallowing exception during message send

java.io.NotSerializableException: akka.persistence.dynamodb.journal.DynamoDBJournal

at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)

at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)

at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)

at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)

at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)

at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)

at akka.serialization.JavaSerializer$$anonfun$toBinary$1.apply$mcV$sp(Serializer.scala:297)

at akka.serialization.JavaSerializer$$anonfun$toBinary$1.apply(Serializer.scala:297)

at akka.serialization.JavaSerializer$$anonfun$toBinary$1.apply(Serializer.scala:297)

at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)


Is any custom serializer  supported by "akka-persistence-dynamodb" plugin??

Our environment detail:
scala version: 2.11.8
akka version: 2.4.12
akka-persistence-dynamodb version: 1.0.1
play version: 2.5.10

Richard Ney

unread,
Feb 21, 2017, 1:06:30 PM2/21/17
to Akka User List
I've had no issues using my custom protocol buffer serializers in my DynamoDB journal tests. I'm using all the same versions you are. Have you enabled Akka debug level logging to see which serializer the framework is trying to use?

Asif Fayyaz

unread,
Feb 22, 2017, 3:23:51 AM2/22/17
to Akka User List
Hi Richard, Thankyou for answering the question. I enabled the debug level logging and saw that the custom serializer is loaded properly. So, it should be used for serialisation of the payload via akka persistence. However, looking into this error, it seems as akka is using default JavaSerializer rather than my custom serializer for avro. Unfortunately, via akka debugging, i am not yet able to see if my custom serializer was even tried by akka. Here are the settings I have for akka debugging:
akka.persistence.journal.plugin = "xxx-dynamodb-journal"
akka {
  loglevel=DEBUG
  receive = on
  autoreceive = on
  lifecycle = on
  log-config-on-start = on
}
akka.actor {
  serialize-messages = on
  serialize-creators = on
  serializers {
    avro = "core.serializer.avro.MyPayloadSerializer"
  }
  serialization-bindings {
    "core.eventpersistence.MyPayload" = avro
  }
}

Richard Ney

unread,
Feb 22, 2017, 3:34:34 AM2/22/17
to akka...@googlegroups.com
Quick question on your definition for "core.eventpersistence.MyPayload" did you remember to extend Serializable?

Your serialization bindings look good, this is what mine look like for a single group of records since BuilderRecord is a trait that I extend.

trait BuilderRecord extends Serializable {
val recordTimestamp: Instant
}
akka {
actor {
serializers {
builder-records = "report.compute.serialization.BuilderRecordsSerializer"
}
serialization-bindings {
"report.compute.model.br.BuilderRecord" = builder-records
}
}
}

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to a topic in the Google Groups "Akka User List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/akka-user/w6mHmHXaen4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to akka-user+unsubscribe@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Asif Fayyaz

unread,
Feb 23, 2017, 1:32:12 AM2/23/17
to Akka User List
Is it still needed if the serialization is not using Java Serialization?? I also tried extending MyPayload with Serializable, but the error is the same. I am going to create a simple example with the issue so that maybe someone can try himself.

To unsubscribe from this group and all its topics, send an email to akka-user+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages