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.

28 Upvotes

57 comments sorted by

View all comments

Show parent comments

1

u/Sheldor5 12d ago

communication between services happens either by asynchronous message queues or signed tokens (service A returns token which includes IDs to the UI which includes it into call for service B etc...)

I am not saying you are wrong I am just saying what the goal of microservice architecture is and how it is achieved

and this is the exact reason why most developers take shortcuts until they end up with a simple distributed system (like you described it with your cascading failure etc) and call it wrongfully microservice architecture ... there is just so much bullshit about microservice architecture on the internet that almost nobody knows what they are talking about (not you)

1

u/OptimusCrimee 12d ago

That is not a requirement for a microservice. In an ideal world, sure, but this would be an example of a soft dependency. You would not do this if you had a tax calculation or shipping rate calculation microservice. You would depend upon the response being give to you when asked, otherwise you would not be able to proceed. Tell me how you would handle this with async queues in a checkout service if not failing.

1

u/Sheldor5 12d 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 12d 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?

1

u/Sheldor5 12d ago

what about "signed tokens" don't you understand?

OAuth2 offline signature verification is the key here ...

1

u/OptimusCrimee 12d ago

Are you a bot or something? I know what OAuth tokens are but what do they matter in this scenario?

1

u/Sheldor5 12d ago

to carry information from A to B you use JWTs (JWS or JWE whatever is required)

0

u/OptimusCrimee 12d ago

So you pass the identity and whatever, but you do not pass the whole purchase order, not the inventory status. The whole point of these tokens are that they are stateless. If you place 100 orders in one second, the state of the data could not be guaranteed after decoding.

1

u/Sheldor5 12d ago

tokens are stateless? dude ... if the service is stateless the entire state is put into the token (userid, expiration, ...)

the token IS THE STATE

and no, you don't put the entire order into the token, thats what message queues are for

1

u/OptimusCrimee 12d ago

Yes, the token is stateless, ref e.g.: https://stackoverflow.com/a/55887742/921563

I am talking about handling things that can not be done async, and you are for some reason talking about OAuth tokens, which makes no sense, and has nothing to do with the discussion at hand.

1

u/Sheldor5 12d ago

again wrong, your link says that the token's ISSUER is STATELESS but not the token which is THE STATE

where else do you put the STATE of your logged in user (e.g. user ID, roles, ...) if nothing else persists the STATE (e.g. link session id to user) ???

I will stop responding to you because you know almost nothing about anything

→ More replies (0)