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

Sdílet
Vložit
  • čas přidán 30. 04. 2022
  • 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

Komentáře • 88

  • @ProgrammingTechie
    @ProgrammingTechie  Před 5 měsíci +5

    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 Před rokem +3

    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 Před rokem

    Very informative video, thanks for your efforts

  • @shariefrana
    @shariefrana Před 7 měsíci

    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.

  • @ouhamzalhouceine8409
    @ouhamzalhouceine8409 Před rokem +2

    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 Před 10 měsíci

      I face the same issue, have you figure out why the error occur?

    • @user-xs5li1uy1c
      @user-xs5li1uy1c Před 4 měsíci

      @@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;
      }

  • @biswaranjanray7338
    @biswaranjanray7338 Před 5 měsíci +1

    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?

  • @m0naco608
    @m0naco608 Před měsícem

    Awesome! ❤

  • @melihcankilic5918
    @melihcankilic5918 Před rokem +1

    very good!

  • @Emerson-mv4hm
    @Emerson-mv4hm Před 2 lety +1

    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!!!

  • @tamerlannusraddinov
    @tamerlannusraddinov Před 2 lety +1

    Thanks for tutorial. Just whant to add that, when inventoryResponses empty then stream.allMatch returns true. Need to add check ifnot empty.

  • @emptytextfield
    @emptytextfield Před rokem

    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

  • @shubhagrawal2169
    @shubhagrawal2169 Před 9 měsíci

    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

  • @yogeez123
    @yogeez123 Před rokem

    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 Před rokem +1

    Pls make the webflux, react tutorial

  • @mohammedsardar3779
    @mohammedsardar3779 Před rokem

    Just a thought to share, InventoryService can be added to OrderSvc as a dependency, and InventoryResponse can be accessed and reused.

  •  Před 4 měsíci

    Using the block() operator is an anti-pattern.
    But thanks for the video.

  • @kennedydre8074
    @kennedydre8074 Před rokem

    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  Před rokem +1

      Thank you, you can check out my Spring Framework tutorial
      czcams.com/video/ZwcHeLhvuq4/video.html

    • @kennedydre8074
      @kennedydre8074 Před rokem

      @@ProgrammingTechie thank you so much.

  • @prajyotgajane4087
    @prajyotgajane4087 Před 2 lety +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  Před 2 lety

      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 Před 2 lety +1

      Bad practice (17:01).

  • @srihariiyengar3913
    @srihariiyengar3913 Před rokem

    I would like to enroll for this training

  • @aashishanegi4790
    @aashishanegi4790 Před 10 měsíci

    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?

  • @dmitriidemianov5686
    @dmitriidemianov5686 Před 10 měsíci

    Hey, how's that rainbow indents plugin called?

  • @Granta_Omega
    @Granta_Omega Před 9 měsíci

    What happens if they order more than is actually in stock?

  • @dorrakadri1474
    @dorrakadri1474 Před 9 měsíci

    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

  • @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]

  • @jagadeeshbabu5227
    @jagadeeshbabu5227 Před 2 lety +1

    Ur shared links for mongodb and spring test are same

  • @borasabrioglu44
    @borasabrioglu44 Před rokem +1

    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  Před rokem +5

      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.

  • @shivdattbibhar_0734
    @shivdattbibhar_0734 Před měsícem

    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

  • @BHUPATHIRAJURAJANRAJU

    why not using feign client??

  • @garvisrobot9274
    @garvisrobot9274 Před 8 měsíci

    Unable to find sku codes order is placed anyways.

  • @manugalaxy14
    @manugalaxy14 Před rokem +1

    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  Před rokem +4

      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 Před rokem

      Any chance you could make a follow up showing how to write a shared library with maven/gradle? Great video, thank you!

  • @amarjeethria1243
    @amarjeethria1243 Před 7 měsíci

    Can you point me to a link which has good content on Java Streams

  • @xdiepx
    @xdiepx Před 2 lety +2

    Wouldn’t this be a coupling? Because order services depends on inventory services to return.

  • @ZsZw
    @ZsZw Před rokem

    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  Před rokem

      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.

  • @Cherupakstmt
    @Cherupakstmt Před 2 lety

    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  Před 2 lety +4

      I will introduce it later in the tutorial, it's part of the plan 🙂

    • @Cherupakstmt
      @Cherupakstmt Před 2 lety

      @@ProgrammingTechie oh ok. Got it

  • @maheshy5168
    @maheshy5168 Před rokem

    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  Před rokem +1

      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 Před rokem

      @@ProgrammingTechie Thank you so much for ur rapid response. Will go through above suggested way
      Thanks again

  • @garvisrobot9274
    @garvisrobot9274 Před 8 měsíci

    Order gets placd even if sku not matches.

  • @hepi1550
    @hepi1550 Před 11 měsíci

    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 Před 9 měsíci

      use @FeignClient declarative mode to call another API easy and conveinance way

  • @bathientran9074
    @bathientran9074 Před 2 lety

    Can you make the same course with quarkus framework

  • @rameshd8436
    @rameshd8436 Před rokem

    Mobile view can't see font

  • @rajraj-xr7qx
    @rajraj-xr7qx Před 2 lety +1

    Next part video when can we expect sir ?

  • @mraihiamine2907
    @mraihiamine2907 Před 8 měsíci

    Hey techie can I use your code as a starting point of a CZcams series thatI would make

  • @barsayten7222
    @barsayten7222 Před rokem

    What is the mean of "OrderLineItems"? What we use for? Can somebody explain?

    • @quanphan7337
      @quanphan7337 Před rokem

      go to your database, select* all tables in your db and you will understand

  • @garvisrobot9274
    @garvisrobot9274 Před 8 měsíci

    Found the issue it was an empty stream.

  • @manjunathg1207
    @manjunathg1207 Před rokem

    Sir can u please send me this project's source code 🙏

  • @_ifly
    @_ifly Před rokem

    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

  • @praveenjha802
    @praveenjha802 Před rokem

    I am getting 404 error request while hiiting the inventory api in postman . can someone please help???

    • @utkarshrastogi7646
      @utkarshrastogi7646 Před 10 měsíci

      did u find a sol

    • @ahmetbahadrayar1468
      @ahmetbahadrayar1468 Před 8 měsíci

      In the InventoryRepository change the "Optional findBySkuCodeIn(List skuCode);" to "List findBySkuCodeIn(List skuCode);"

  • @user-cw6pb9cs3l
    @user-cw6pb9cs3l Před rokem

    Spring Data MongoDB Tutorial: I think you mistake here with a link

  • @sujithg5873
    @sujithg5873 Před 2 lety

    How to handle fallback here?

    • @ProgrammingTechie
      @ProgrammingTechie  Před 2 lety

      This will be part of the Circuit Breaker Pattern video, which will be covered in Part 6

  • @_ifly
    @_ifly Před rokem

    at 26:24 czcams.com/video/D_XxZU72yMw/video.html it's giving me an Error: Field 'id' doesn't have a default value. how to solve this problem please

  • @nicholas1460
    @nicholas1460 Před 2 lety +1

    Why would you have REST communication between internal services? Such a waste.

    • @ProgrammingTechie
      @ProgrammingTechie  Před 2 lety +1

      Sure we can use gRPC, I didn't want to make this tutorial more complicated.

    • @nicholas1460
      @nicholas1460 Před 2 lety

      @@ProgrammingTechie Tried and true messaging probably best.

  • @deanclancy6448
    @deanclancy6448 Před 2 lety

    What is the point of the Product Service?

    • @ProgrammingTechie
      @ProgrammingTechie  Před 2 lety +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 Před 2 lety

      @@ProgrammingTechie why is it created so

    • @deanclancy6448
      @deanclancy6448 Před 2 lety

      Thanks. It was good to learn how to connect to MongoDB anyway

    • @BryanPham027
      @BryanPham027 Před rokem

      @@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 Před 3 měsíci

    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

  • @utsavgalphat
    @utsavgalphat Před rokem

    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