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

Поделиться
HTML-код
  • Опубликовано: 17 дек 2024

Комментарии • 91

  • @ProgrammingTechie
    @ProgrammingTechie  10 месяцев назад +6

    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 Год назад +4

    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

  • @biswaranjanray7338
    @biswaranjanray7338 10 месяцев назад +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?

  • @emptytextfield
    @emptytextfield Год назад +1

    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

  • @shariefrana
    @shariefrana Год назад

    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.

  • @tamerlannusraddinov
    @tamerlannusraddinov 2 года назад +2

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

  • @maheshd3506
    @maheshd3506 2 года назад

    Very informative video, thanks for your efforts

  • @emersonribeiro-eu
    @emersonribeiro-eu 2 года назад +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!!!

  • @ouhamzalhouceine8409
    @ouhamzalhouceine8409 2 года назад +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 Год назад

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

    • @HòaVõ-m6x
      @HòaVõ-m6x 9 месяцев назад

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

  • @borasabrioglu44
    @borasabrioglu44 Год назад +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  Год назад +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.

  • @melihcankilic5918
    @melihcankilic5918 Год назад +1

    very good!

  • @m0naco608
    @m0naco608 6 месяцев назад

    Awesome! ❤

  • @Sreeni_JavaTechie
    @Sreeni_JavaTechie 20 дней назад

    @Programming Techie : Could you please display the error message " Product is not in stock , please try again later" in the POSTMAN instead in IntelliJ Idea console

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

  • @shubhagrawal2169
    @shubhagrawal2169 Год назад

    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

  • @jagadeeshbabu5227
    @jagadeeshbabu5227 2 года назад +1

    Ur shared links for mongodb and spring test are same

  • @manugalaxy14
    @manugalaxy14 Год назад +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  Год назад +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.

    • @lukejriddle1
      @lukejriddle1 Год назад

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

  • @huythongnguyen1565
    @huythongnguyen1565 9 дней назад

    I have just started learning your course, but I'm not sure which chapter to begin with. I see two courses on Spring Microservices. One of them is a project example. Could you please guide me on where to start?

  • @mohammedsardar3779
    @mohammedsardar3779 Год назад

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

  • @dorrakadri1474
    @dorrakadri1474 Год назад

    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

  • @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  Год назад +1

      Thank you, you can check out my Spring Framework tutorial
      ruclips.net/video/ZwcHeLhvuq4/видео.html

    • @kennedydre8074
      @kennedydre8074 Год назад

      @@ProgrammingTechie thank you so much.

  • @knowledgeshare1622
    @knowledgeshare1622 2 года назад +1

    Pls make the webflux, react tutorial

  • @aashishanegi4790
    @aashishanegi4790 Год назад

    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?

  • @Granta_Omega
    @Granta_Omega Год назад

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

  • @garvisrobot9274
    @garvisrobot9274 Год назад

    Unable to find sku codes order is placed anyways.

  • @srihariiyengar3913
    @srihariiyengar3913 Год назад

    I would like to enroll for this training

  • @xdiepx
    @xdiepx 2 года назад +2

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

  • @prajyotgajane4087
    @prajyotgajane4087 2 года назад +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 года назад +1

      Bad practice (17:01).

  • @dmitriidemianov5686
    @dmitriidemianov5686 Год назад

    Hey, how's that rainbow indents plugin called?

  • @amarjeethria1243
    @amarjeethria1243 Год назад

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

  • @mraihiamine2907
    @mraihiamine2907 Год назад

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

  • @shivdattbibhar_0734
    @shivdattbibhar_0734 6 месяцев назад

    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

  •  10 месяцев назад

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

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

  • @hepi1550
    @hepi1550 Год назад

    The block() method should not be used and generates an error. Is there any other way to create synchronous inter services communication?

    • @HenazeriBoutique
      @HenazeriBoutique Год назад

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

  • @ZsZw
    @ZsZw 2 года назад

    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  2 года назад

      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.

  • @BHUPATHIRAJURAJANRAJU
    @BHUPATHIRAJURAJANRAJU 2 года назад

    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 года назад +4

      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]

  • @maheshy5168
    @maheshy5168 2 года назад

    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  2 года назад +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 2 года назад

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

  • @_ifly
    @_ifly Год назад

    at 26:24 ruclips.net/video/D_XxZU72yMw/видео.html it's giving me an Error: Field 'id' doesn't have a default value. how to solve this problem please

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

  • @bathientran9074
    @bathientran9074 2 года назад

    Can you make the same course with quarkus framework

  • @rajraj-xr7qx
    @rajraj-xr7qx 2 года назад +1

    Next part video when can we expect sir ?

  • @garvisrobot9274
    @garvisrobot9274 Год назад

    Order gets placd even if sku not matches.

  • @praveenjha802
    @praveenjha802 2 года назад

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

    • @utkarshrastogi7646
      @utkarshrastogi7646 Год назад

      did u find a sol

    • @ahmetbahadrayar1468
      @ahmetbahadrayar1468 Год назад

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

  • @rameshd8436
    @rameshd8436 2 года назад

    Mobile view can't see font

  • @nicholas1460
    @nicholas1460 2 года назад +1

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

    • @ProgrammingTechie
      @ProgrammingTechie  2 года назад +1

      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.

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

  • @manjunathg1207
    @manjunathg1207 Год назад

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

  • @deanclancy6448
    @deanclancy6448 2 года назад

    What is the point of the Product Service?

    • @ProgrammingTechie
      @ProgrammingTechie  2 года назад +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

    • @BryanPham027
      @BryanPham027 2 года назад

      @@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)

  • @garvisrobot9274
    @garvisrobot9274 Год назад

    Found the issue it was an empty stream.

  • @ArturAzizean
    @ArturAzizean Год назад

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

  • @MuraliRamPerigisetty
    @MuraliRamPerigisetty 9 месяцев назад

    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 Год назад

    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