Quantcast
Channel: Akka Libraries - Discussion Forum for Akka technologies
Viewing all articles
Browse latest Browse all 1362

Issue with Custom DurableStore in Akka Cluster: Deserialization Error for DurableDataEnvelope

$
0
0

Issue with Custom DurableStore in Akka Cluster: Deserialization Error for DurableDataEnvelope

I’m working on a custom DurableStore implementation in Akka Cluster using Java. My goal is to persist Akka’s Distributed Data (ddata) using a custom logic that serializes the data and stores it in a file.

Here’s the relevant configuration I’ve set up:

Akka Configuration:

akka.cluster {
    sharding {
        remember-entities = on
        remember-entities-store = ddata

        distributed-data {
            durable.keys = ["*"]
            durable.store-actor-class=com.zoho.actor.cluster.durable.CustomDurableStore
        }
    }
}

akka.actor {
    serializers {
        proto = "akka.cluster.ddata.protobuf.ReplicatorMessageSerializer"
    }

    serialization-bindings {
        "akka.cluster.ddata.DurableStore$DurableDataEnvelope" = proto
    }
}

Serialization Logic:
I am able to serialize DurableDataEnvelope successfully:

public static byte[] serializeToString(DurableDataEnvelope envelope) throws Exception {
    serializer = serialization.findSerializerFor(envelope);
    // Serialize to byte array
    byte[] serializedBytes = serializer.toBinary(envelope);
    return serializedBytes;
}

Deserialization Logic:
However, when I try to deserialize the data, I encounter the following error:

java.io.NotSerializableException: Unimplemented deserialization of message with manifest [akka.cluster.ddata.DurableStore$DurableDataEnvelope] in [akka.cluster.ddata.protobuf.ReplicatorMessageSerializer]

Here is the code for deserialization:

public static DurableDataEnvelope deserializeFromString(byte[] serializedBytes) throws Exception {
    DurableDataEnvelope ddata = (DurableDataEnvelope) serialization.deserialize(serializedBytes, DurableDataEnvelope.class).get();
    return ddata;
}

I have configured the serializer binding for DurableDataEnvelope as shown above. Despite that, it seems that deserialization is not correctly implemented or there’s something I’m missing.

Question:
What could be causing this deserialization issue, and how can I resolve it? Is there a specific step I’m missing when configuring or handling the deserialization for DurableDataEnvelope?

TIA!


5 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 1362