0

Please ignore English grammar.

For Learning purpose I want to create a microservice project in Spring and I download some sample project and now I have some very basic idea of microservices. But I am confused how I start my own project. I want to implement the following simple use case.

In my database I have three table Product, ProductStock and Order and I want to write microservice for each table.

Product microservice will have end point for crud operation. ProductStock microservice will only have update stock and check stock end point. Order microservice will only have posting order operation.

I create a multi module maven project and now I have following question.

1: Is creating multi module maven project is the only way to create microservices project.

2: I am using Hibernate so in which module(microservice) I create model classes. I need model classes in every module(microservice). (Model classes are Product, ProductStock and Order).

3: Where I set hibernate confiuration.

2 Answers 2

1

Even if this question is way too broad, i'll try to answer your question as good as i can:

  1. A multimodule project is not the only way (and i would even say, not a recommended way for different services). Usually you have completely separated Maven projects for each service.

  2. Every service has to have its own data model and entity classes. Services should never share any entities, and should not access the same databases/schemas. They can use the same database server with different schemas.

  3. In every service, which uses Hibernate.

Sign up to request clarification or add additional context in comments.

3 Comments

So order service before it confirm the order it need to communicate with stock service to check product availability so stock service will have its own database and order service will have different database? and for communication messaging is best or rest client?
Yes, the services need to communicate with each other to get the necessary information. If HTTP oder messaging is better, is for you to decide. It depends on your requirements, on your environment etc.
can you share some advance micro-services project repository link.
1

The microservice architecture is not a trivial area so I would suggest to you that you start with some theory first. One of the books which is often referred here and there is Building Microservices By Sam Neuman. I highly recommend reading it or at least a part of it. This is the theoretical part.

Then for some hands on experiences you may want to clone/fork the PiggyMetrics project. This is an educational project but at the same time it contains quite a lot of patterns and advanced stuff.

After that you will be able to answer your own questions yourself, albeit there will be much more to ask ;-)

Good luck!

1 Comment

Thanx Lachezar Balev

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.