Akka persistance custom TCK plugin , How to support non java serialization for Tagged type?

Hey All ,

I am building Akka persistence plugin with Apache ignite , i have a question when it comes to event tagging , if i disable java serialization , Tagged classes failed to be serialized properly , is there a way to configure specific serialization for Event Tagged or it need to be handled in the plugin itself , the GitHub for my plugin : https://github.com/Romeh/akka-persistance-ignite

The exception i get :
[2018-11-21 21:20:48] [orderManagerSystem-akka.actor.default-dispatcher-27] ERROR a.p.i.journal.IgniteWriteJournal - Attempted to serialize message using Java serialization while akka.actor.allow-java-serialization was disabled. Check WARNING logs for more details.
akka.serialization.DisabledJavaSerializer$JavaSerializationException: Attempted to serialize message using Java serialization while akka.actor.allow-java-serialization was disabled. Check WARNING logs for more details.
[2018-11-21 21:20:48] [orderManagerSystem-akka.actor.default-dispatcher-11] WARN a.s.DisabledJavaSerializer - Outgoing message attempted to use Java Serialization even though akka.actor.allow-java-serialization = off was set! Message type was: [class akka.persistence.journal.Tagged]

I have a sample application where this issue is happening for me when I use Protobuf for events serialization :

In Apache ignite , it is binary serialization .

Thx a lot for your help!

You mean events wrapped in `akka.persistence.journal.Tagged’?
The journal should unwrap such events and only serialize the events themselves. The tags are typically stored in a separate column that can be queried.

Hey Patriknw ,

Thanks for your reply , Yes for the Tagged class , I know the journal need to unwrap them and store then separately , i was asking is it possible to specify non Java default serializer like Protobuf so i can disable Java serialization completely ?

Thx a lot

What is serializing the Tagged? If you don’t do it in the plugin I don’t see where it would be serialized. It’s a local actor message between the PersistentActor and the journal actor.

Actually the issue got fixed by checking the msg type if it is Tagged event or not before doing the actual event storing in the journal , something like :

private JournalItem convert(PersistentRepr p) {
    if (p.payload() instanceof Tagged) {
        Tagged taggedMsg = (Tagged) p.payload();
        PersistentRepr persistentReprWithoutTag = new PersistentImpl(taggedMsg.payload(), p.sequenceNr(), p.persistenceId(), p.manifest(), p.deleted(), p.sender(), p.writerUuid());
        return new JournalItem(persistentReprWithoutTag.sequenceNr(), persistentReprWithoutTag.persistenceId(), serializer.toBinary(persistentReprWithoutTag), JavaConverters.asJavaCollection(taggedMsg.tags()));
    } else {
        return new JournalItem(p.sequenceNr(), p.persistenceId(), serializer.toBinary(p), null);
    }

}

I’d recommend against serializing/storing the PersistentRepr unless you have the limitation of a key-value store with only a single value per key. Better to serialize/store the event payload and all other fields separately.

Thanks for your advice but unfortunately i have the limitation of key value store per key otherwise i will have to create multiple key value stores for the same key which will lead to multiple insert and read for each journal item so performance wise will be bad .

Thanks again for your support !