13 Using WebClient to make API calls - Spring Boot Microservices Level 1

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 ธ.ค. 2024

ความคิดเห็น •

  • @bazar9000
    @bazar9000 3 ปีที่แล้ว +112

    Sync and Async are like in the post office.
    Sync - When you go to take your package you wait inline till your number comes and
    then you are served (wasting time and stopping all your daily tasks).
    Async - you get your number via SMS and you keep with the rest of the
    day and when your turn arrives you get a message on your phone to come
    and get your package.

    • @jasper5016
      @jasper5016 2 ปีที่แล้ว +4

      Wonderful analogy. Thanks

  • @Stannis24
    @Stannis24 4 หลายเดือนก่อน +3

    man this is a gold mine even if is 5 years old, really good explanation

  • @paracha3
    @paracha3 3 ปีที่แล้ว +6

    He is really good teacher. Very unique style of explaining.

  • @JayPatel12928
    @JayPatel12928 2 ปีที่แล้ว +10

    Just one correction I guess. 10:51 here the word "Mono" doesn’t really refer to the promise aspect of the async call, rather as the name suggests, all it means is the response value, if at all, is going to be a singular value and not a list of values (which again is called "Flux" in this whole sping reactive web ecosystem). This distinction is very important to the functional programming paradigm and hence its introduction to this ecosystem as well.

  • @silentkiller4009
    @silentkiller4009 3 ปีที่แล้ว +1

    Brilliant explanation !!

  • @pavankumar-si2jv
    @pavankumar-si2jv 5 ปีที่แล้ว +7

    truely amazing tutorial!

  • @ltmikepick
    @ltmikepick 3 ปีที่แล้ว

    These days when workshops could be made with other people in the same room....So great...So good...

  • @Manuel-ug5fg
    @Manuel-ug5fg 10 หลายเดือนก่อน

    You couldn't have explained it better.
    Thanks!

  • @pramoddwivedi1640
    @pramoddwivedi1640 2 ปีที่แล้ว

    Your are great Sir ,the way of teaching is awesome

  • @orhanibm8270
    @orhanibm8270 4 ปีที่แล้ว +12

    BodyToMono is like a McDonald's receipt. At the store when you order your food, the cashier prints out a receipt with an order number on it and hands it over to you (A promise that you will get your food). The order is routed to kitchen for preparation while you are waiting for your food to be cooked (A fetch, a db query, a file read in our case), and when the food is ready, the cashier calls your number and voila, you got your food (a db result, a json response from an api call). What I am not clear is what if request is rejected? Say my burger type is sold out and kitchen responds that we don't have such meat available anymore? How does it work in the case of BodyToMono?

    • @TahirHussainMir24
      @TahirHussainMir24 4 ปีที่แล้ว

      Can we configure our producer api to send the result say JSON with some parameters set like 'error : cannot process the request because blah blah' and then at consumer side, the model will have that field which matches that parameter and gets built by bodyToMono?

  • @eirikbremnes2860
    @eirikbremnes2860 5 ปีที่แล้ว +9

    Awesome tutorial....you're great as always! Txs :)

  • @Guillotineman
    @Guillotineman 5 ปีที่แล้ว +3

    like all your videos, right to the point, super well explained. QUALITY!

  • @haimmichalashvili8251
    @haimmichalashvili8251 4 ปีที่แล้ว

    You are awsome, thanks for taking care of teaching us the new way of WebClient instead of using the deprecated RestPattern :)

  • @DevCurioso
    @DevCurioso 5 ปีที่แล้ว +3

    Cant wait for the workshop with WebClient =D

  • @shashankfuley6455
    @shashankfuley6455 3 ปีที่แล้ว +8

    This channel has the most distracting content , when ever I visit this channel looking for a solution , I always get carried away by the content that is not necessary for that particular instance of time . Great Work!!!!!

  • @JonathanLennartson
    @JonathanLennartson 3 ปีที่แล้ว

    Awesome tutorial! Great teaching!

  • @PhuongHuynh-qm5th
    @PhuongHuynh-qm5th ปีที่แล้ว

    Thanks for this great tutorial!

  • @Abhishek-tr4oi
    @Abhishek-tr4oi 4 ปีที่แล้ว +3

    His shirt changed instantly. Wow that's magic😁.... btw loving this series so far.

  • @ujjwolbhandari
    @ujjwolbhandari 5 ปีที่แล้ว +2

    Wonderful job! Thanks a lot for such a clear explanation.

  • @ujjwolbhandari
    @ujjwolbhandari 5 ปีที่แล้ว +7

    Should we have created a WebClient bean with WebClient.builder().build() instead of a builder bean so that we would reuse that same instance of WebClient for all our api calls?

    • @jorgexfd
      @jorgexfd 5 ปีที่แล้ว

      i have the same doubt

    • @SuperKako17
      @SuperKako17 4 ปีที่แล้ว

      Yep, there's nothing request-specific to the client instance being built.

    • @ajayjiutube
      @ajayjiutube 2 ปีที่แล้ว +1

      Check if that is thread safe, it is quite possible your instance is serving a request and it is handed over to next incoming request, it might get corrupted and you will get unexpected and unwanted results. Please reply your findings if you already have tried this, its been 2 years you asked this question.

  • @rajivjha123
    @rajivjha123 5 ปีที่แล้ว +4

    Hi Kaushik, You have AsyncRestTemplate already for async calls . Can you please explain us the difference between ASyncRestTemplate Vs WebClient ?

  • @nbtpavankumar
    @nbtpavankumar 4 ปีที่แล้ว

    Awesome explanation . Hope we have a Work Shop on the WebClient Async ....

  • @cihanseven6227
    @cihanseven6227 4 ปีที่แล้ว

    Excellent work, you are a good man and I wish you the best.. Thank you very much.

  • @neelamg3363
    @neelamg3363 4 ปีที่แล้ว

    Awesome very nice !!

  • @fernandonatividade5315
    @fernandonatividade5315 5 ปีที่แล้ว

    Awesome content! It's perfect for who wants to learn a little bit about microservices

  • @caesar5555
    @caesar5555 5 ปีที่แล้ว

    AMAZING Workshop!!!!!!!!!!!! THANK YOU!!!!!!!!!!!

  • @lkarthik1985
    @lkarthik1985 3 ปีที่แล้ว

    Thanks lot for this excellent video

  • @RudraBhattacharya2
    @RudraBhattacharya2 5 ปีที่แล้ว

    Very good illustration..

  • @imranshaikh115
    @imranshaikh115 5 ปีที่แล้ว

    Very easy and straightforward , i like the way

  • @rabithbo7089
    @rabithbo7089 4 ปีที่แล้ว

    Big thanks to this man!

  • @NavedKhan-je7el
    @NavedKhan-je7el 5 ปีที่แล้ว

    Awesome Kaushik, You are doing a great job.

  • @fsociety2871
    @fsociety2871 4 ปีที่แล้ว +1

    Shouldn't be the return value of .build() from the web client builder specified as @Bean ? as invoking .build() will create instance every time a new request comes?

  • @GuitarreroDaniel
    @GuitarreroDaniel 4 ปีที่แล้ว

    Amazing explanation, thank you very much. This seems easier than Retrofit.

  • @muanomakhokha2929
    @muanomakhokha2929 ปีที่แล้ว

    Give this men a bells🥃

  • @harishjrao1257
    @harishjrao1257 3 ปีที่แล้ว

    Very understandable, thanks

  • @mosup5007
    @mosup5007 4 ปีที่แล้ว +2

    its a great series but i want to point to something.
    I think we shouldn't block at all as this kills the purpose of using reactive programing
    you can change the type of -ratings- to a flux
    and use ratings.flatmap(rating -> ... )
    and then inside the flatMap() after .bodytoMono().map(movie -> new CatalogItem(...)); and return that.

    • @anarodriguezfernandez75
      @anarodriguezfernandez75 4 ปีที่แล้ว

      He is not doing reactive programming

    • @mosup5007
      @mosup5007 4 ปีที่แล้ว +1

      @@anarodriguezfernandez75 he pointed to that in the following videos

    • @jasonfang4879
      @jasonfang4879 2 ปีที่แล้ว

      No

  • @kam33p
    @kam33p 5 ปีที่แล้ว +1

    I've a question, what if we've a kafka topic that we consume from and want to make a rest post, and the service that produces to this is faster than the rest post request. Will a webclient work faster than a regular resttemplate and will the service still have to wait for the response before committing offsets in the kafka topic?

  • @RakhiDhavale
    @RakhiDhavale 3 ปีที่แล้ว

    nicely explained

  • @AhmedKhaled-he9mf
    @AhmedKhaled-he9mf 3 ปีที่แล้ว

    Very thanks for nice explain
    Please question, for call web service, as performance(fast, memory, CPU) which better, Client Jersey or WebClient Spring??

  • @mirac03
    @mirac03 4 ปีที่แล้ว

    Wonderful job! Thank you!.

  • @sariyaansari4096
    @sariyaansari4096 3 ปีที่แล้ว +1

    After a long time I could see and learn something valuable... very great content and very good organization.... but I think if you add a separate level 4 and level 5 for webclient and api gateway it will be great
    This is really much needed for people who wanted to learn web client properly and api gateway
    I have started recommending this channel to others to learn something from here

  • @asmitasengar8008
    @asmitasengar8008 4 ปีที่แล้ว

    Thanks it's very helpful

  • @infiniteviolins8971
    @infiniteviolins8971 3 ปีที่แล้ว

    i like hearing the sound of the keyboard clicks in this video. it's peaceful. hahahahaa.

  • @nupuragrawal4406
    @nupuragrawal4406 3 ปีที่แล้ว

    Please prepared a series on spring boot reactive programming

  • @saurabhkannawar
    @saurabhkannawar ปีที่แล้ว

    @Kaushik, when to use .block() and not to?

  • @nilendru
    @nilendru 5 ปีที่แล้ว

    Learned as well as enjoyed all the videos in this series. In video 13 at 11.30, I think you can relate it with callable Future in java executer framework wherein we get the actual object returned by call after thread execution finishes by future.get () method in asynchronous way.

  • @lazarmarkovic8152
    @lazarmarkovic8152 3 ปีที่แล้ว

    Hello, I have one question. In microservice design, and interservice communication. How to pass authorization header(JWT token) from microservice A to microservice B in WebClient call? But to avoid setting header every time in each web client request.

  • @vickymsvikas
    @vickymsvikas 2 ปีที่แล้ว

    Hello Kaushik, Great work explaining each and every minute detail, thank you !! Could you also please share the repository link of this code?

  • @vedio1227
    @vedio1227 4 ปีที่แล้ว

    Great Work, Crystal Clear. But i have a question regarding performance of webclient in synchronous calls comapred to that of rest template?

  • @TheRayapudisandeep
    @TheRayapudisandeep 4 ปีที่แล้ว

    Koushik, thanks for the great videos. Your videos are just WONDERFUL resources. You mentioned about RxJava workshop in this video. Do you have any plans to do it?

  • @The.Good.Gamer.Ps5
    @The.Good.Gamer.Ps5 3 ปีที่แล้ว

    Netty is a server right? How Netty and Tomcat are running togethar?

  • @Anoopegi
    @Anoopegi 3 ปีที่แล้ว

    you are making singleton but what happen if a try to hit same end point at same point from different browsers?

  • @hoanNguyen-lf8xr
    @hoanNguyen-lf8xr 3 ปีที่แล้ว

    what's the benefit of using WebClient with block mechanism vs traditional RestTemplate?

  • @yanshunji
    @yanshunji 4 ปีที่แล้ว

    Thanks ! How can we get the status code of the response ? and why the webclient running very slow with my local Java 11 and spring 5 ?

  • @zr60
    @zr60 2 ปีที่แล้ว

    How do I get back a collection of items? or a nested json object if the API collects that.

  • @prakashgunjari1996
    @prakashgunjari1996 3 ปีที่แล้ว

    Hi Kaushik..Can you please make a video on asynchronous and reactive programming

  • @ChetanVijay29
    @ChetanVijay29 4 ปีที่แล้ว +3

    Kindly make playlist on reactive programming with web flux and mysql db

    • @ksk235
      @ksk235 4 ปีที่แล้ว +1

      As of now, using web flux with mysql is futile. Mysql JDBC driver for Java is synchronous by default and last time I checked Oracle hasn't made any declaration about making an asynchronous JDBC driver for MySql. So You can actually use Web flux with MySql but the db calls won't be async. Although there's a workaround with a third party driver called Jasync but that's not very useful as you don't have Spring Data JPA support for that.

  • @tolulopeayemobola1446
    @tolulopeayemobola1446 3 ปีที่แล้ว

    Hi
    thanks for your video.
    how does one include body in his request. I m using the init method to build my base url and then I am creating a method to do a get operation.
    I placed my headers as default in the init method and then I want to build a body in order to snd request to the token creation endpoint
    It doesnt seem smooth to me. How is it done?

  • @chebrolusowjanya3114
    @chebrolusowjanya3114 ปีที่แล้ว

    Can we make asynchronous call( using webclient) between two applications.

  • @ericzachman3615
    @ericzachman3615 3 ปีที่แล้ว

    Thanks for your videos. C# dev here, trying to catch up on everything I’ve missed out on in Java since 1995. Does Java itself have a better word or moniker for the concept of a future or promise? Mono seems like a terrible word for that, or is it just me? What am I missing? Does Java have an async/await mechanism like c# or Js?

  • @prithvisharma3597
    @prithvisharma3597 3 ปีที่แล้ว

    if i replace Movie.class in body to mono, to String.class, will it return me the string which i want ?

  • @sahildogra7843
    @sahildogra7843 4 ปีที่แล้ว

    Is there any example of consuming https url using webclient ? Getting SSL erros.

  • @abdullahkhaled6162
    @abdullahkhaled6162 3 ปีที่แล้ว

    I have a question when we write .block() at the end does this means that we are blocking the thread or it means we are writing in a synchronous fashion like async-await in javascript

  • @sinfonico1984
    @sinfonico1984 ปีที่แล้ว

    To me the question is how you mock this web clients? for example with Mockito....

  • @raveendrajonna4756
    @raveendrajonna4756 3 ปีที่แล้ว

    Any playlist from Javabrain - on reactive programing

  • @trinhduyhung8211
    @trinhduyhung8211 5 ปีที่แล้ว

    Great stuff

  • @pulkitmalhotra7323
    @pulkitmalhotra7323 3 ปีที่แล้ว

    Any example of Webclient with SSL (one way or two way SSL)?.

  • @shivanshbajpai588
    @shivanshbajpai588 ปีที่แล้ว +1

    So I guess in this scenario after using block() there is actually no difference in restTemplate and WebClient

  • @syedarbaz3781
    @syedarbaz3781 2 ปีที่แล้ว

    I understand what you explained..
    But how's it Asynchronous....how webclient is asynchronous....couldnt get....it's is still blocking and after getting result moving forward.....

  • @rajendrasahu855
    @rajendrasahu855 5 ปีที่แล้ว

    awesome tutorials sir..

  • @vivekpaliwal1876
    @vivekpaliwal1876 9 หลายเดือนก่อน

    Use of mono is still not clear ..you are using block...how it is better then resttemplate? After get call api call thread is waiting or dead?

  • @praveenkumark772
    @praveenkumark772 4 ปีที่แล้ว

    How to cache the response we get from the service call which we make via webclient??

  • @daanishsarguru1170
    @daanishsarguru1170 4 ปีที่แล้ว

    Thank you so much for this

  • @mohsinmd2662
    @mohsinmd2662 ปีที่แล้ว +2

    Mono is like that one friend of mine who promises to give me my money back... but never does 😢... and why is it a mono? its one friend, and he is the only friend i got.

  • @SuperKako17
    @SuperKako17 4 ปีที่แล้ว

    Great stuff. However, isn't calling `block()` blocking the execution after *every request*? Why not make them all and then block until they all resolve (eg, the JS `Promise.all()` way)? Or am I misunderstanding this? :D

    • @SuperKako17
      @SuperKako17 4 ปีที่แล้ว

      OK, found the way to make the calls in parallel using `Mono.zip` method.

  • @narendra_ingle
    @narendra_ingle 4 ปีที่แล้ว

    What happens when we have multiple class into service stub and we got request as string then how can we mapping class name ?
    bodyTomono(?)

  • @leemp337
    @leemp337 2 ปีที่แล้ว

    thanks dude.

  • @edukondalugumma3753
    @edukondalugumma3753 5 ปีที่แล้ว

    You are ultimate sir, thank you...!

  • @gudiya1491
    @gudiya1491 ปีที่แล้ว

    It's not working for me it's giving dns query timeout exception .. could you please tell why am I getting this error?

  • @rahuljoshi456
    @rahuljoshi456 4 ปีที่แล้ว

    Can we use WebClient for APIs over HTTP2?

  • @anshulagarwal6682
    @anshulagarwal6682 11 หลายเดือนก่อน

    How can we put request params and request body or header in api request from spring boot

  • @amprabhleenkaur
    @amprabhleenkaur 2 ปีที่แล้ว

    I am getting nullpointer exception. Any suggestions?

  • @PixelLoafLatte
    @PixelLoafLatte 4 ปีที่แล้ว

    Is there a tutorial about spring webflux by java brain here?

  • @shubhamdixit6097
    @shubhamdixit6097 4 ปีที่แล้ว

    Well if you have a experinece with node js ,Mono is basically a promise in node js

  • @pereiradouglas
    @pereiradouglas 4 ปีที่แล้ว

    great tutorial, help me so much!
    I looking for it but cant found in other places!

  • @nehajain6751
    @nehajain6751 4 ปีที่แล้ว

    Thanks a lot Koushik..!!
    could anybody please share the link to learn asynchronous reactive programming using webClient ; if Koushik has already posted?
    if not Koushik please try to make a series on Async programming in java springboot.
    Thanks in advance.

  • @kuldeepmore7847
    @kuldeepmore7847 4 ปีที่แล้ว

    How can we setup proxy? Need to access third party services

  • @rubalprakash3103
    @rubalprakash3103 5 ปีที่แล้ว +1

    can you make a video on WebSockets, sir!

  • @tudorpop3579
    @tudorpop3579 5 ปีที่แล้ว

    consider using Retrofit instead of RestTemplate/webclient to get nice and clean code

  • @idireney
    @idireney 5 ปีที่แล้ว

    We can use Reactive Programming with SGBDR like Oracle don't think so cause it's compatible with cassandra mongoDB and other no sql sgbd is it true ?

  • @ChandanKumar-lb4lb
    @ChandanKumar-lb4lb 4 ปีที่แล้ว

    What is the springboot version here?

  • @stefanrusu2067
    @stefanrusu2067 23 วันที่ผ่านมา

    almost 6 years later and RestTemplate is still here and not deprecated anymore in Spring 6 :)

  • @chetanr121
    @chetanr121 ปีที่แล้ว

    I wanted to know how to store the data after consuming the api to database

  • @usmanjawaid5362
    @usmanjawaid5362 4 ปีที่แล้ว

    how you're going to call WebClient from other technology such as React.js

  • @Azyro777
    @Azyro777 3 ปีที่แล้ว

    when I add dependency for spring-boot-starter-webflux, I couldn't resolve WebClient and got this error message : "Dependency 'org.springframework.boot:spring-boot-starter-webflux:2.5.0' not found". Is it because I'm using Java 16?

    • @Dongoske123
      @Dongoske123 3 ปีที่แล้ว

      Did you ever find a solution to this?

    • @educatedraja4511
      @educatedraja4511 2 ปีที่แล้ว

      @@Dongoske123 Hey I solved it by doing the following steps:
      IntelliJ->File->invalidate Caches... -> select the checkmark on 'Clear VCS Log caches and indexes' -> Invalidate and Restart

  • @nareshgoud1905
    @nareshgoud1905 5 ปีที่แล้ว

    Super sir...... Thanks a lot:)

  • @alex1602
    @alex1602 5 ปีที่แล้ว

    Nice episodes man, really nice how you explain those things.

  • @esterlib4627
    @esterlib4627 4 ปีที่แล้ว

    Could not autowire. There is more than one bean of 'Builder' type.
    Beans:
    getBuilder (MovieCatalogServiceApplication.java) webClientBuilder (WebClientAutoConfiguration.class)

  • @bhuwantripathi2707
    @bhuwantripathi2707 3 ปีที่แล้ว

    Facebook notification should be an example of asynchronous? Which comes regularly in backend

  • @tomaszmachura1422
    @tomaszmachura1422 4 ปีที่แล้ว

    Thanks for the great video. In my case, when I am trying to use block() to make the call synchronous, I get the following error: java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-4
    No idea on how to fix that :/

    • @swiss_ch
      @swiss_ch 4 ปีที่แล้ว

      It is explained here: stackoverflow.com/questions/64838936/how-to-use-spring-webclient-to-make-synchronous-call/64845627#64845627