Reputation: 31
This is similar to How to deserialize from a file to different class. But, I'm developing micro-services using Dropwizard.
I have two services, service A and service B. I have a message queue (RabbitMQ) setup between the two services.
I am trying to send an object of type Class A (defined in service A) from service A to service B. I have not imported class A in service B. However in service B i have Class B defined which is exactly same as Class A.
I am getting a ClassNotFoundException: Class A in service B when service B tries to deserialize and typecast the object to Class B.
I want the two jars to be as independent as possible. Is there a way to do this.
Upvotes: 0
Views: 423
Reputation: 694
You can use Apache Avro for serializing (predefined avro schema) your objects between two service or if you want to use a queue bewteen them. On top you will lower the needed network bytes, because apache avro serialization is really good.
You can also use CatainProto or ProtoBuffer, but I like the apache avro method.
Upvotes: 1