0

Maybe someone already asked this question but after some searches I still don't find an answer.

I have multiple Spring Boot applications which should communicate to each other via events streaming and REST calls. To enforce DTOs consistency I would like to use Apache Avro to generate Java classes but I don't know where to store Avro schemas.

Say App1 should call App2, so App2 generates DTOs schemas that App1 will use to consume its data. Where can I store App1's schemas so that App2 can take them to generate Java classes needed.

On the same way, App1 publishes messages on Redis and other applications that read those messages need to deserialize to Java object using Avro schemas, it would be very usefull if I could centralized those schemas somewhere.

I use Maven and Avro maven plugin.

Thanks a lot for your help.

akuma8
  • 4,160
  • 5
  • 46
  • 82

2 Answers2

0

You can create a APP_commons service which will cater to the avro schemas, which will contain the respective methods to generate the values/data that each APP needs.

APP_commons can be added as a dependency in the pom of APP1 and APP2.

Hope this helps! Also you can use feign clients.

Suzy
  • 1
  • 3
  • Thanks for your answer, but why not adding all DTOs in that APP_commons jar? I would like to avoid doing a common jar – akuma8 Feb 24 '20 at 14:59
  • You can do that. In that case you will need to use Feign clients to call between the two microservices. – Suzy Feb 25 '20 at 07:08
0

I found a solution with this Spring Cloud project https://github.com/spring-cloud/spring-cloud-schema-registry It provides excatly what I need.

akuma8
  • 4,160
  • 5
  • 46
  • 82