RestClient in Spring Boot 3 - Builder, Timeout, Interceptor, RequestFactory

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ก.ค. 2024
  • In today’s video, we’re going to explore RestClient from Spring Framework 6, Spring Boot 3. Recently, I answered a question
    from Reddit, asking if is there any resource to get Production experience, from my thought, we can start getting familiar with Production depending on how much we understand about our system and the tools/components we’re using. System side can be hard for junior level, but I think understanding tools/components is the simplest and must-go way to get started in gaining Production experience at any level.
    Github: github.com/nlinhvu/rest-clien...
    You Might Already Know Series: • You Might Already Know
    References:
    RestClient::Spring Framework 6: docs.spring.io/spring-framewo...
    RestClient::Spring Boot 3: docs.spring.io/spring-boot/do...
    (00:00): Introduction
    (00:44): Practice when using RestClient
    (05:08): Create a RestClient
    (09:00): Set Connection/Response Timeout through RequestFactory
    (13:30): RestClient Interceptors
  • วิทยาศาสตร์และเทคโนโลยี

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

  • @jurgen5557
    @jurgen5557 3 หลายเดือนก่อน

    Again, my friend, such great content! Unlike many other channels, you manage to present rather advanced Spring topics in a very clear way, making it easy and a pleasure to follow. I repeat myself, but each vid I learn something new, though I know myself a thing or two here :-).
    My highlight here were the ClientRequestFactories and its Spring support as Settings class. Did not know about it..

    • @linhvudev
      @linhvudev  2 หลายเดือนก่อน

      Thanks again, as always, I really appreciate you leaving your comment!

  • @debbh274
    @debbh274 2 หลายเดือนก่อน

    Still a fan of your open telemetry series. Awesome work. And great examples.

    • @linhvudev
      @linhvudev  2 หลายเดือนก่อน

      Really appreciate your nice words, many thanks!

  • @nnh1005
    @nnh1005 3 หลายเดือนก่อน

    Tất cả video trên kênh rất chất lượng ạ, cảm ơn a ❤

    • @linhvudev
      @linhvudev  3 หลายเดือนก่อน

      thank you very much 😊😊!

  • @matsior_
    @matsior_ 2 หลายเดือนก่อน

    Nice video! Do you think interceptors should be registered as spring beans? Or just creating new one when we need as in yours example?

    • @linhvudev
      @linhvudev  2 หลายเดือนก่อน +1

      Nice question! It simply depends on your interceptor can be shared across multiple RestClient instances (if you have multiple RestClient instances). For example: all RestClient instances intercept a request to add a same headers to downstream services => you can register 1 interceptor bean and inject it to all instances. But if your interceptor behaves different for every services, new Interceptor(String hiServiceToken) for HiService, new Interceptor(String helloServiceToken) for HelloService => you need to create 1 interceptor instance for 1 RestClient instance. Avoid making stateful interceptors, it's a different story, anyway, yeah, understand what you're using.

    • @matsior_
      @matsior_ 2 หลายเดือนก่อน +1

      Do you think interceptor is good place to call some SSO? When we need additional authorization in request

    • @linhvudev
      @linhvudev  2 หลายเดือนก่อน +1

      @@matsior_ yes, it absolutely is, RestClient.interceptor is WebClient.filter in Reactive context. In Reactive, you'll have ServerOAuth2AuthorizedClientExchangeFilterFunction is already supported. But the similar thing in RestClient is being developed, an issue was raised nearly a year ago github.com/spring-projects/spring-security/issues/13588, an draft version is also discussed there, you could take a look.

  • @kam1234554321
    @kam1234554321 10 วันที่ผ่านมา

    Sorry but after 3 minutes I was unable to finish the video. It's so diffucult to follow when you are skipping/changing letters in word like "Servid" instead of "Service" or "lient" instead of "client" (and you keep repeating these words many many times) or other like "lelved" instead of "level", "experiend" instead of "experience". I'm not sure why but you were able to pronounce "c" letter in "documentation" (and you are able to pronounce "s" letter as well) but you change it in all other words. I had to rewind the video few times and listen to it again but after 5 minutes I realized I'm still 3 minutes into the video.
    I believe this video is very informative but even on the weekend in my free time I don't have 1h to watch this video (with rewinding every 10 seconds because I didn't get what you are saying).
    Before anyone says "chill dude, it's his accent, he is not a native speaker". Well, me too as you can notice by reading this comment (I bet I did some mistakes) but you were able to follow my message till this sentence which means it's good enough to understand me.
    It's a honest opinion about the video. He can try to improve next time and someone had to say it. Cheers