Thorum357
Thorum357

Reputation: 221

Microservices and jpa

I like the idea of microservices and think that I understand the basic idea.

I want to make a System of microservices, where each service is a seperate spring-boot project. For Example with two services, Service-A and Service-B. B has some JPA Entities and A makes a Request with RestTemplate to B.

RestTemplate.getForObject(...)needs the Class Type it should return. So must I also include the entities classes in the Service-A (seperate project) or is there a better way to send the Values of the Entities to other services.

I hope I did explain good enough my problem.

Upvotes: 4

Views: 1927

Answers (1)

AlVaz
AlVaz

Reputation: 766

I've seen two ways to handle this:

1) Common library defining shared complex types - You have a project for Service A and a project for Service B, you also need a project for lib-alpha, maybe another project for lib-beta, etc. This would be a Java implementation of domain-specific complex types that multiple services could leverage

2) Craft a well-documented API and leave it up to the consumers to fend for themselves - This usually involved defining a high-level data encoding scheme (using XML, JSON, etc) and serializing data in Service A before sending data needed to the API provider which then deserializes it on receipt

Upvotes: 1

Related Questions