WegenenVerkeer / akka-persistence-postgresql

An akka-persistence plugin for Postgresql
MIT License
40 stars 25 forks source link

Is this ignoring `manifest(o: Object)`? #34

Closed kungfoo closed 5 years ago

kungfoo commented 5 years ago

I am trying to use protobuf to serialize objects into binary to use this storage and I cannot get my SerializerWithStringManifest to use the actual returned content of the manifest() method. Is it possible that this is ignored?

Following are my config and SerializerWithStringManifest implementations (java):

  actor {
    allow-java-serialization = off
    serializers {
      userEvents = "sample.UserEventSerializer"
      userSnapshots = "sample.UserSnapshotSerializer"
    }
    debug {
      lifecycle = on
    }

    serialization-bindings {
      "sample.Users" = userSnapshots
      "sample.UserCreated" = userEvents
      "sample.UserDeleted" = userEvents
    }
  }

  persistence {
    journal.plugin = "pg-journal"
    snapshot-store.plugin = "pg-snapshot"
  }
}
public class UserEventSerializer extends SerializerWithStringManifest {
    @Override
    public String manifest(Object o) {
        if (o instanceof UserCreated) {
            return "user.created";
        }
        if (o instanceof UserDeleted) {
            return "user.deleted";
        }
        return "";
    }
}

This plugin keeps on using the FQN of the classes as the manifest, so deserialization fails when I match for the strings that are returned from manifest().

Is this an unsupported form of usage?

ghost commented 5 years ago

@kungfoo we have had the same issue with cluster messages not deserialising. It appears that the jounral store https://github.com/WegenenVerkeer/akka-persistence-postgresql/blob/develop/modules/akka-persistence-pg/src/main/scala/akka/persistence/pg/journal/JournalStore.scala always uses the FQN, see line 82, so you are forced to use the FQN in your implementation. Not only is this not very nice it breaks the default serialization for cluster messaging. This really needs addressing.

kwark commented 5 years ago

fixed by https://github.com/WegenenVerkeer/akka-persistence-postgresql/pull/42