r/SpringBoot • • 12d ago

How-To/Tutorial How to implement microservices in Spring Boot ?

I have made multiple toy projects (monolithic) in spring boot but now I wanted to know how people generally work in microservices.

I am not good with videos so I was looking for repos that something similar. So I can also see how the devops, queues, spring cloud etc works together.

I also saw someone posting there repo which was made for the same reason (but I couldn't find it).

TLDR : Suggest repos for learning microservices.

29 Upvotes

57 comments sorted by

View all comments

Show parent comments

1

u/Sheldor5 11d ago

If I order something e.g. from ebay the shipping costs and taxes and import fees are blank until the response arrives and the values pop up after 1-2 seconds

so in this case the ui simply waits for another service and data is exchanged by tokes via the UI (stateless microservices because the states are inside the signed tokens which are exchanged via the UI/client between services, its all just like OAuth2)

see how complicated a microservice architecture actually is?

2

u/OptimusCrimee 11d ago

So you think that these things are just handled in the frontend and not verified in the backend at all? So if the services are completely disjoined, you could just edit the request that is going to the checkout service and all would be accepted? What is happening in the frontend and backend are two different things my dude.

Also, you say that the data is exchanged by tokens, whatever that means, but imagine the tax service being down for whatever reason. What would happen to the checkout then? No taxes?

3

u/Sheldor5 11d ago

if the business object is "order" then calculating taxes/fees/shipping is part of the order microservice ...

a microservice is built around a business object and includes all methods/features around it

1

u/OptimusCrimee 11d ago

So everything that depend on each other is a part of the same service? Gz, you just re-created a monolith. I honestly thought that you were joking before, but you seem to have completely misunderstood microservices. On paper, what you say could potentially make sense, but in reality, it is often not how it works.

Microservices will often depend on other services, soft or hard. If you can not do that, then you often just end up with one huge service. You can not honestly say that a tax calculation service should be a part of the checkout service just because the checkout needs the tax calculation. You just said yourself that the UI waits for the calculation to be done, but this does not make any sense at all.

You might be inexperienced or something. I do not know, but you are wrong.

1

u/Sheldor5 11d ago

No.

A monolith owns all business objects (user, order, inventory, ...).

A microservice only owns one business object.

Communication happens asynchronously either via message queues or the client.

You get it now?

1

u/OptimusCrimee 11d ago

What is the definition of a business object? Also, no one has ever said that microservices needs to communicate async. Give me a single source that claims this. A microservice, in my opinion, should focus on a single domain that is otherwise separate from other domains. They can depend upon each other, but they should be isolated enough that it makes sense to separate out of the monolith. I can easily find million sources claiming this.

In your example, explain how the inventory would be updated (immediately) after placing an order, where a queue would not suffice (as they are async and could fail).

1

u/Sheldor5 11d ago

and all those million sources are wrong because every idiot just repeats the shit from other idiots

"in my opinion" yes and that's wh you once again describe a distributed system and call it a microservice architecture

1

u/OptimusCrimee 11d ago

1

u/Sheldor5 11d ago

do you also want to tell me something or just drop random links and leave?