serializationhazelcast

hazelcast serialisation when not using common dto


My scenario:

1.) separate quarkus app with hazelcast

2.) another quarkus app as hazelcast client that reads data from hazelcast from app 1

I don't want to have shared objects in a common library to avoid service cuppling

When I write a dto class to 1. and want to read it on 2 I get class not found exception ... but I have the same class in both applications under the same package. If I put the class in a separate mvn module and import the module in both project it works ok but I would like to avoid that source od cuppling

Any hints on how to solve this issue?


Solution

  • You can not expect Java to deserialize an object that it does not know.

    There are alternatives though

    1. Using SQL bindings

    This works by creating mappings on the data structure. Then you can use Hazelcast SQL dialect to access the data structure. This way your Java client can execute SQL sentences.

    See https://docs.hazelcast.com/hazelcast/latest/sql/mapping-to-maps

    1. Using GenericRecord

    This works by making the data structure store data as GenericRecord type. You can access the fields by string constants. See https://docs.hazelcast.com/imdg/latest/clusters/accessing-domain-objects