Spring Boot Microservices Project Example - Part 2 | Inter Service Communication

  Рет қаралды 89,211

Programming Techie

Programming Techie

2 жыл бұрын

Spring Boot Microservices Project Example - Part 2 | Inter Service Communication
Source Code
github.com/SaiUpadhyayula/spr...
⭐️⭐️You can check out other Full Stack Project Oriented Tutorials in my Channel ⭐️⭐️
Spring Data MongoDB Tutorial: • Spring Boot Testing Tu...
Spring Boot Testing Crash Course Tutorial: • Spring Boot Testing Tu...
⭐️⭐️ You can follow me on Social Media through the below Links⭐️⭐️
Twitter: / sai90_u
Blog: programmingtechie.com/
Dev.to: dev.to/saiupadhyayula
Facebook Page: / programmingtechie

Пікірлер: 89
@ProgrammingTechie
@ProgrammingTechie 4 ай бұрын
NOTE: This tutorial is using outdated as it's using Spring Boot 2, I am working on an update for this tutorial. Please refer to the github repo, whenever you are facing any issue with the dependency or compilation errors: github.com/SaiUpadhyayula/spring-boot-microservices
@juancaos01
@juancaos01 Жыл бұрын
I love the fact that you choice web client to sync communication and the way that you explain it, you're amazing. Thank you!, also I love the fact that you're very organized and that you teach to use construct injections instead of field injection. 10/10
@maheshd3506
@maheshd3506 Жыл бұрын
Very informative video, thanks for your efforts
@shariefrana
@shariefrana 6 ай бұрын
Great presentation, love the way you teach, I guess there's a minor bug here that we need to consider the Order quantity as well to find the available inventory stock for each skucode.
@Emerson-mv4hm
@Emerson-mv4hm 2 жыл бұрын
Nice! We should add a service discovery so we dont have the need to specify the ports. That’s probably what you’ll do in the next one, right? Great video! Thanks!!!
@ProgrammingTechie
@ProgrammingTechie 2 жыл бұрын
Exactly 🙂
@melihcankilic5918
@melihcankilic5918 Жыл бұрын
very good!
@m0naco608
@m0naco608 Ай бұрын
Awesome! ❤
@biswaranjanray7338
@biswaranjanray7338 4 ай бұрын
Excellent series to start with microservices. Absolutely loved the series. Thanks you. Lots of things to learn. Java promotes code reusability as a programming paradigm. The InventoryResponse class from the Inventory DTO is duplicated in Order Service DTO. We also faced a similar situation while migrating from a monolith to microservices. To handle the situation we created a module with common classes and added that module as a dependency to all the microservices. Pros is, code duplication is avoided and the microservices are still deployed as independent entity. Cons is, the common module has to be built before building any of the microservices. Whats the best practice to share a dto across microservices?
@yogendraamarji7285
@yogendraamarji7285 Жыл бұрын
Really its a awesome content it can be great if we have an user registration and login also with authorization and authentication after login only user will able to access other services
@tamerlannusraddinov
@tamerlannusraddinov 2 жыл бұрын
Thanks for tutorial. Just whant to add that, when inventoryResponses empty then stream.allMatch returns true. Need to add check ifnot empty.
@emptytextfield
@emptytextfield Жыл бұрын
at 23:37 is replacing by a method reference the correct code? I did not see any methods for getting the isInStock variable inside the InventoryResponse class
@kennedydre8074
@kennedydre8074 Жыл бұрын
Hi, I love your tutorial thus far, and you make so easy to understand and follow you. I was wondering if you had a beginner course on Spring boot that explains concepts like bean etc? Thank you in anticipation of your response.
@ProgrammingTechie
@ProgrammingTechie Жыл бұрын
Thank you, you can check out my Spring Framework tutorial kzbin.info/www/bejne/kKjGeZiCnduop5Y
@kennedydre8074
@kennedydre8074 Жыл бұрын
@@ProgrammingTechie thank you so much.
@prajyotgajane4087
@prajyotgajane4087 2 жыл бұрын
Great Tutorial so far!! I am actually coding along with you, I have just one question, not sure if you already took care of it in the future videos, but after placing the order from order service, shouldn't the inventory table column quantity decrease by the quantity ordered ?
@ProgrammingTechie
@ProgrammingTechie 2 жыл бұрын
Thanks, I actually didn't want to spend too much time coding the business logic, The plan is to concentrate more on the microservice concepts. So yes, the inventory update part is missing, but I will not be covering in the future tutorials too.
@EventuSocialClub
@EventuSocialClub 2 жыл бұрын
Bad practice (17:01).
@mohammedsardar3779
@mohammedsardar3779 Жыл бұрын
Just a thought to share, InventoryService can be added to OrderSvc as a dependency, and InventoryResponse can be accessed and reused.
@yashjain7644
@yashjain7644 Жыл бұрын
how?
@borasabrioglu44
@borasabrioglu44 Жыл бұрын
is the skucode really enough as a request param? dont we also have to include the quantity? for example if there are 3 iphones ordered and only 2 in stock it should fail. but if you go to min 17:47 the isInStock method does not check for quantity, it checks only if there is at least one item in stock... or am i thinking wrong? thanks in advance and thanks for the video...really helpful.
@ProgrammingTechie
@ProgrammingTechie Жыл бұрын
Please note that the implementation is not perfect and have gaps. I was mainly concentrating on getting to the more interesting parts, that's why I took some shortcuts during implementation.
@ouhamzalhouceine8409
@ouhamzalhouceine8409 Жыл бұрын
Bug sur, for example if we have a order request with at least on skuCode instock, and others skucodes not existing in database, we can always place Order!! 😇 { "orderLineItemsDtoList":[ { "skucode": "iphone_13", "price": 100, "quantity":1 }, { "skucode": "bla_bla", "price": 100, "quantity":1 } ] } any way that's a Great Tutorial, i learn a lot thanks
@jackfeng9202
@jackfeng9202 9 ай бұрын
I face the same issue, have you figure out why the error occur?
@user-xs5li1uy1c
@user-xs5li1uy1c 3 ай бұрын
@@jackfeng9202 my solution @Transactional(readOnly = true) @Override public List isInStock(List skuCode) { int skuReq = skuCode.size(); List inventories = inventoryRepository.findBySkuCodeIn(skuCode); int skuRes = inventories.size(); List results = new ArrayList(); for (Inventory inventory : inventories) { if (skuReq != skuRes) { throw new IllegalArgumentException("Sku code not valid"); } else { results.add(InventoryResponseDTO.builder() .skuCode(inventory.getSkuCode()) .isInStock(inventory.getQuantity() > 0) .build()); } } return results; }
@yogeez123
@yogeez123 Жыл бұрын
Why should we check for each item if available or not before ordering ? We could have probably set a flag in product service so that we don't display item if not in stock or label as out of stock. Checking of each item in OrderController is not something I would go for.
@knowledgeshare1622
@knowledgeshare1622 Жыл бұрын
Pls make the webflux, react tutorial
@shubhagrawal2169
@shubhagrawal2169 8 ай бұрын
instead of sending back Inventory Response to Order Service then check all match or not , i think it is better to check in Inventoryservice and sending back true/false
@srihariiyengar3913
@srihariiyengar3913 Жыл бұрын
I would like to enroll for this training
4 ай бұрын
Using the block() operator is an anti-pattern. But thanks for the video.
@manugalaxy14
@manugalaxy14 Жыл бұрын
Hey, one question: Why duplicate the InventoryResponse class? If these two services are designed to communicate with each other, we could add the inventory dto as a dependency to the order-service project, right?
@ProgrammingTechie
@ProgrammingTechie Жыл бұрын
That's one way to go usually you have the option to either maintain the required classes as shared library and add them as dependency (or) duplicate the classes across the services You can go with either option.
@unchecked_exception
@unchecked_exception Жыл бұрын
Any chance you could make a follow up showing how to write a shared library with maven/gradle? Great video, thank you!
@dmitriidemianov5686
@dmitriidemianov5686 9 ай бұрын
Hey, how's that rainbow indents plugin called?
@aashishanegi4790
@aashishanegi4790 9 ай бұрын
I am getting 404 error request while hitting the inventory API in postman. As a result I am unable to get the Out of stock message and Order placed successfully message. Could you please tell me how to fix it?
@jagadeeshbabu5227
@jagadeeshbabu5227 2 жыл бұрын
Ur shared links for mongodb and spring test are same
@Granta_Omega
@Granta_Omega 8 ай бұрын
What happens if they order more than is actually in stock?
@dorrakadri1474
@dorrakadri1474 8 ай бұрын
what about relationships im so confused so we have for exemple student that have many courses and each one is a microservice how can we do this
@xdiepx
@xdiepx 2 жыл бұрын
Wouldn’t this be a coupling? Because order services depends on inventory services to return.
@404ErrorGodNotFound-jh9rt
@404ErrorGodNotFound-jh9rt 4 ай бұрын
Loose coupling it is.
@BHUPATHIRAJURAJANRAJU
@BHUPATHIRAJURAJANRAJU Жыл бұрын
why not using feign client??
@Cherupakstmt
@Cherupakstmt 2 жыл бұрын
For interservice communication why can't we use feignclient instead of webclient. Feignclient can be integrated with spring API Gateway for load balancing and url routing very easily. Can you check on that too.
@ProgrammingTechie
@ProgrammingTechie 2 жыл бұрын
I will introduce it later in the tutorial, it's part of the plan 🙂
@Cherupakstmt
@Cherupakstmt 2 жыл бұрын
@@ProgrammingTechie oh ok. Got it
@nehemiahlimocheburet1411
@nehemiahlimocheburet1411 Жыл бұрын
Now, I have a problem adding EurekaClientAnnotation, the maven dependency was dowloaded but I have this error: java: cannot find symbol symbol: class EnableEurekaClient, anyone facing the same issue [spring-cloud version: 2022.0.2]
@ZsZw
@ZsZw Жыл бұрын
allMatch would cause problem since the stream is empty then true is returned. E.g. if you order iPad your order still would be placed even your inventory has no iPad.
@ProgrammingTechie
@ProgrammingTechie Жыл бұрын
You are right, I didn't put much thought into the logic as I was mainly thinking about creating surrounding services, this logic will have multiple edge cases to handle, I will update the source code once the tutorial is completed.
@garvisrobot9274
@garvisrobot9274 7 ай бұрын
Unable to find sku codes order is placed anyways.
@amarjeethria1243
@amarjeethria1243 6 ай бұрын
Can you point me to a link which has good content on Java Streams
@shivdattbibhar_0734
@shivdattbibhar_0734 13 күн бұрын
Can anybody tell me why i am getting this error while running the inventory service ....... Name for argument of type [java.util.List] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag
@bathientran9074
@bathientran9074 2 жыл бұрын
Can you make the same course with quarkus framework
@ProgrammingTechie
@ProgrammingTechie 2 жыл бұрын
Sorry no plans to do this in the near future.
@hepi1550
@hepi1550 11 ай бұрын
The block() method should not be used and generates an error. Is there any other way to create synchronous inter services communication?
@user-iy7fo8bg5f
@user-iy7fo8bg5f 9 ай бұрын
use @FeignClient declarative mode to call another API easy and conveinance way
@maheshy5168
@maheshy5168 Жыл бұрын
Hi, This Tutorial is really helpful. Thanks is not enough but a million thanks. Please help with below query interviewer: How are you securing ur APIs/endpoints me: we implemented security by using JWT interviewer: if I have an API and that API internally calls an external API, how do you authenticate the external API? are you using the same jwt token to authenticate internal/external APIs? or if you are using 2 jwt tokens, then u r calling JWT server twice which is not good? So actually he confused me, and I was blank Please give me a perfect solution, Thanks in advance
@ProgrammingTechie
@ProgrammingTechie Жыл бұрын
Hi, The answer depends on how you define an external API, is the external API secured by the same authorization server ? ( In your words jwt server ?) Then there is no need to get another token from the server, you can simply use this token itself. Spring Cloud Gateway can do this automatically for you, it's called as Token Relay, google about it to know more details. If the external API is not secured by the same authorization server, ie, you are calling an API outside your organization, then you have to call the respective authorization server and get a new JWT. You can checkout the older microservices series in my channel, refer to the updated video on API Gateway and Keycloak, I explained this in detail.
@maheshy5168
@maheshy5168 Жыл бұрын
@@ProgrammingTechie Thank you so much for ur rapid response. Will go through above suggested way Thanks again
@mraihiamine2907
@mraihiamine2907 7 ай бұрын
Hey techie can I use your code as a starting point of a KZbin series thatI would make
@ProgrammingTechie
@ProgrammingTechie 7 ай бұрын
Sure make sure to mention this tutorial 😄
@rajraj-xr7qx
@rajraj-xr7qx 2 жыл бұрын
Next part video when can we expect sir ?
@ProgrammingTechie
@ProgrammingTechie 2 жыл бұрын
On Tuesday about Service Discovery
@rajraj-xr7qx
@rajraj-xr7qx 2 жыл бұрын
@@ProgrammingTechie thanks sir
@nicolasardizzoli4207
@nicolasardizzoli4207 2 жыл бұрын
@@ProgrammingTechie thanks you!!
@barsayten7222
@barsayten7222 Жыл бұрын
What is the mean of "OrderLineItems"? What we use for? Can somebody explain?
@quanphan7337
@quanphan7337 Жыл бұрын
go to your database, select* all tables in your db and you will understand
@garvisrobot9274
@garvisrobot9274 7 ай бұрын
Order gets placd even if sku not matches.
@rameshd8436
@rameshd8436 Жыл бұрын
Mobile view can't see font
@praveenjha802
@praveenjha802 Жыл бұрын
I am getting 404 error request while hiiting the inventory api in postman . can someone please help???
@utkarshrastogi7646
@utkarshrastogi7646 9 ай бұрын
did u find a sol
@ahmetbahadrayar1468
@ahmetbahadrayar1468 8 ай бұрын
In the InventoryRepository change the "Optional findBySkuCodeIn(List skuCode);" to "List findBySkuCodeIn(List skuCode);"
@sujithg5873
@sujithg5873 2 жыл бұрын
How to handle fallback here?
@ProgrammingTechie
@ProgrammingTechie 2 жыл бұрын
This will be part of the Circuit Breaker Pattern video, which will be covered in Part 6
@garvisrobot9274
@garvisrobot9274 7 ай бұрын
Found the issue it was an empty stream.
@manjunathg1207
@manjunathg1207 Жыл бұрын
Sir can u please send me this project's source code 🙏
@nicholas1460
@nicholas1460 2 жыл бұрын
Why would you have REST communication between internal services? Such a waste.
@ProgrammingTechie
@ProgrammingTechie 2 жыл бұрын
Sure we can use gRPC, I didn't want to make this tutorial more complicated.
@nicholas1460
@nicholas1460 2 жыл бұрын
@@ProgrammingTechie Tried and true messaging probably best.
@_ifly
@_ifly Жыл бұрын
at 26:24 kzbin.info/www/bejne/epC7qY2LbJesg9k it's giving me an Error: Field 'id' doesn't have a default value. how to solve this problem please
@user-cw6pb9cs3l
@user-cw6pb9cs3l Жыл бұрын
Spring Data MongoDB Tutorial: I think you mistake here with a link
@deanclancy6448
@deanclancy6448 2 жыл бұрын
What is the point of the Product Service?
@ProgrammingTechie
@ProgrammingTechie 2 жыл бұрын
Just created it as a standalone service, Initially also wanted to create a UI, for this tutorial, ie. fetch the products from product service and then place the order, but I changed my mind and just left the service as it is.
@abderrahmenhelaoui6511
@abderrahmenhelaoui6511 2 жыл бұрын
@@ProgrammingTechie why is it created so
@deanclancy6448
@deanclancy6448 2 жыл бұрын
Thanks. It was good to learn how to connect to MongoDB anyway
@nh0zheo413
@nh0zheo413 Жыл бұрын
@@ProgrammingTechie Can you do the complete tutorial for the Product Service? I would like to learn how I can implement the backend to the frontend(UI)
@user-vm4xb2me1e
@user-vm4xb2me1e 3 ай бұрын
you actually wasting time bro, the reason why we come to the springboot because of all the configurations to do in maven project and you are again doing all by yourself. you know you can directly call the springboot projects and make a communication between them using API gateway
@_ifly
@_ifly Жыл бұрын
in the postman when i click send it's giving me an exception "java.sql.SQLException: Field 'id' doesn't have a default value". how to solve this problem all my code is the same
@utsav_g
@utsav_g Жыл бұрын
anybody facing issue with lombok builder I am getting many things but it is not working java: cannot find symbol symbol: method builder() location: class com.utech.inventoryservice.dto.InventoryResponse
Spring Boot Microservices Project Example - Part 3 | Service Discovery
30:59
Spring Boot Microservices Project Example - Part 1 | Building Services
1:35:06
Programming Techie
Рет қаралды 420 М.
I wish I could change THIS fast! 🤣
00:33
America's Got Talent
Рет қаралды 30 МЛН
ТАМАЕВ vs ВЕНГАЛБИ. ФИНАЛЬНАЯ ГОНКА! BMW M5 против CLS
47:36
Spring Boot Microservices Project Example - Part 5 | Security
30:13
Programming Techie
Рет қаралды 60 М.
Top 25 Microservice Interview Questions Answered - Java Brains
39:54
API Gateway | Microservice
11:48
Telusko
Рет қаралды 60 М.
Microservices using SpringBoot 3.0 | Full Example [NEW]
1:25:38
Daily Code Buffer
Рет қаралды 167 М.
Microservices explained - the What, Why and How?
18:30
TechWorld with Nana
Рет қаралды 813 М.
Java Spring Boot 14 Years Interview Experience [God Level Skills]
54:49
Creating a Service Registry | Microservice
9:19
Telusko
Рет қаралды 21 М.
I wish I could change THIS fast! 🤣
00:33
America's Got Talent
Рет қаралды 30 МЛН