A First Look at the new Rest Client in Spring Boot 3.2

Sdílet
Vložit
  • čas přidán 7. 09. 2023
  • This is my first look at the new Rest Client in Spring Boot 3.2. In this tutorial we will discuss what a client is, what are the different implementations of clients available and how to get started with the new Rest Client in Spring Framework 6.1 and Spring Boot 3.2
    🔗Resources & Links mentioned in this video:
    GitHub Repo: github.com/danvega/rest-client
    Http Interfaces: • Spring HTTP Interface ...
    👋🏻Connect with me:
    Website: www.danvega.dev
    Twitter: / therealdanvega
    Github: github.com/danvega
    LinkedIn: / danvega
    Newsletter: www.danvega.dev/newsletter
    SUBSCRIBE TO MY CHANNEL: bit.ly/2re4GH0 ❤️
  • Věda a technologie

Komentáře • 66

  • @hayrullahyasar
    @hayrullahyasar Před 11 měsíci +3

    Thank you for sharing. I like the new Rest Client.

  • @avdain
    @avdain Před 11 měsíci +4

    Super excited for this feature! 🙌🏼

  • @Nico-ly7lh
    @Nico-ly7lh Před 16 dny

    Thank you! We are re-building some clients, will directly remove the resttemplate with this new restclient to be safe for upcoming Spring updates

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

    Awesome video, thank you ☺️

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

    Thank you for sharing.

  • @AleksandarT10
    @AleksandarT10 Před 11 měsíci +15

    We need a new JdbcClient video as well!. Anyway the ParametrizedTypeReference stuff is lame a bit to write it still.

    • @DanVega
      @DanVega  Před 11 měsíci +11

      Recording today!

    • @janetkalu3064
      @janetkalu3064 Před 11 měsíci +1

      Thank you so much, you are a gem

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

      That's true still we r using parameterisedTypeReference , it could have been better if just toList() kind of method and let compiler figure out the type

    • @M_Jaggard
      @M_Jaggard Před 11 měsíci +1

      Sadly while the compiler can figure out the type, it doesn't give that info to the method so there's no way at runtime for it to know how to create the individual objects.
      Having said that, turning something into a List is SUCH a common thing to do that ``".bodyToListOf(Post.class)" or similar would be useful.

  • @AmandeepSingh-hd8iq
    @AmandeepSingh-hd8iq Před 10 měsíci

    Awesome video Dan. Love watching your live demos. As a side question: what theme is it? It's so elegant.

  • @Anbu_Sampath
    @Anbu_Sampath Před 11 měsíci +1

    RestClient with Declarative Interface client is nice combo.

  • @the00one45
    @the00one45 Před 11 měsíci +2

    Great video! Does the new rest client have a more convenient way to handle concurrent requests than the rest template? One big advantage of the web client compared to the rest template for me was that successive calls can be handled a lot quicker because they dont have to wait for another.

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

    never used restclient, used resttemplate before so i will try this now.

  • @VerhoevenSimon
    @VerhoevenSimon Před 11 měsíci +2

    I really like the enhancements, now to hopefully get a more elegant solution for ParametrizedTypeReference in a future release.

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

    i love this one

  • @awjamesfrj
    @awjamesfrj Před 11 měsíci +1

    Very good info! How does rest client deals when the external service is unavailable or returns some error? Does rest client support circuit breaker handling?

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

    With HTTP Interface in place, since you replaced PostService with it, you could remove PostService at the end 😊

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

    Hi Dan, Thats awesome 👍
    Would you like to make a vidoe about how to setup and solve comon issue with hikari?

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

    Great content Dan. Thanks for posting this video.
    One question, I used to use FeignClient and we have I way to log all the request, response, urls, headers, etc. Do you have any idea how we can do the same with RestClient?

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

    Is there a way to remove Post record also, or we have to have it with the same structure as on remote REST endpoints that you call with RestClient? (Bc of that body to entity mapping)

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

    Really cool! Do you know if this new shiny thing has Eureka discovery built in and if that's the case is the authentication stuff passed to the discovered service. Reason for asking, I'm using feign today to call other services (and Eureka) but auth is not passed when using Feign which can be solved uisng an interceptor but it's clunky. I'd rather see that the Rest Client have this built in :-)

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

    Hi Dan, perfect timing on this. I wasn't able to get the default header to work, but I did get this to work:
    ResponseEntity response = restClient.post()
    .uri("/contacts?email={email}&first_name={first_name}&lists[]={listId}", email, firstName, listId)
    .header("Authorization", "Bearer " + token)
    .contentType(MediaType.APPLICATION_FORM_URLENCODED)
    .retrieve()
    .toBodilessEntity();

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

    Hello Dan, Thanks for wonderfull video, Can you make one video on aws lamda for spring boot database access whether to use orm like hibernate or spring data jpa or spring JDBC which one is best suited

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

    What are the main differences between Rest Client and the Feign client (or Spring Cloud OpenFeign) ? Are there scenario's where one is preferred over the other?

    • @glebivashyn5962
      @glebivashyn5962 Před 7 měsíci +2

      I was actually wondering the same. Would be really cool to see a video diving into comparison of those

  • @dandantin
    @dandantin Před 7 dny

    Where did you get this spring t-shirt? It's awesome.

  • @wagdynavas6337
    @wagdynavas6337 Před 11 měsíci +1

    Do you recommend RestClient to make micro services calls?

  • @rickhunter8216
    @rickhunter8216 Před 11 měsíci +1

    NICE T-SHIRT

  • @peshutanpavri1599
    @peshutanpavri1599 Před 5 měsíci

    Hey this is great, so if I wanted to do an Integrated test with @SpringBootTest, I could just use this client directly right ?

  • @user-un1um2vf3y
    @user-un1um2vf3y Před 10 měsíci

    bro, thanks for video. but what about errorHandler, restTemplate had amazing option as ResponseErrorHandler, may be restClient has similar option too?

  • @user-hn1hn1kn5k
    @user-hn1hn1kn5k Před 6 měsíci

    Cool, thanks! What about (1) proxies (2) SSL (self-signed, enterprise CA, ...) (3) error handling ?

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

    I have 2 issues using RestClient with Spring Boot 3.2. First one is in the builder I set a baseUrl bit I have to prepend the baseUrl on every get() or post() request but I don't know why - makes no sense to me. The other thing is, when I compile a native build, the application cannot find a HttpMessageConverter for my request object which should be converted to JSON. This works finde with Java 21 but not compiled to a native application. Does anyone know why?

  • @azenkwed
    @azenkwed Před 6 měsíci

    I am getting a 405 Method not allowed for the methods POST, PUT and DELETE. Only the GET Methods work. Any idea?

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

    Does this provide any support to call APIs with Mtls?

  • @loic.bertrand
    @loic.bertrand Před 2 měsíci

    Is there a way to disable SSL verification on the RestClient? Like the TrustAllStrategy for the SSLContext in Apache HttpClient (without having to use the HttpClient as a request factory for the RestClient)

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

    I might miss something. Is the RestClient built on top of OkHttp? The code syntax is almost the same as OkHttp.

  • @s3cario475
    @s3cario475 Před 6 měsíci

    Hey, what's a plugin which help to copletly words?

  • @hamednikbakht9708
    @hamednikbakht9708 Před 11 měsíci +2

    how to send token for this

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

    If there is an Authorisation token(oauth - Apigee) API call before the real API call how do we make 2 calls here?
    Also, if the Api calling is massl, can you show how to implement that with restclient

  • @user-xo4hk2ir9l
    @user-xo4hk2ir9l Před 9 měsíci

    And Spring Feign client. Is it a good choice too? What is your opinion about? Thank you for the greate video o/

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

    yeah but this seem not so much different compare to ResponseEntity, does it have better performance ?

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

    You're missed huge and impotant thing here.. error handling.. not everytime you have data on the other end.. so you have two type of errors, expected ones like 'errorCode': 11, which is not in your regular POJO file.. and unxpected ones like .. gateway error in http response.. 500 errors with something weird in body and last errors without HTTP error like API return always 200 but sometimess like "error": "not found item" intead of item object. Can this annotation handle all the cases?

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

    what theme is that?

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

    How to configure RestClient with OAuth2 to call protected endpoints

  • @orhn
    @orhn Před 11 měsíci +2

    Is “DeleteMapping” typo while others are Exchange?

    • @DanVega
      @DanVega  Před 11 měsíci +1

      Yes, just a typo. Thanks for letting me know.

  • @attoumak
    @attoumak Před 11 měsíci +2

    In the interface why do you use @DeleteMapping instead of @DeleteExchange?

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

      Just a typo

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

      @@DanVega Since your tests passed, that means we can use MVC annotations in interface declaration?

  • @ashishranjan9731
    @ashishranjan9731 Před 5 měsíci

    Can you please compare with feignclient

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

    Clearly there is big misunderstanding with rest template. I worked with 2 compagnies that decide to replace all rest template/opeinfeign clients with webclient because of the misunderstanding

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

      By the way if I'm not wrong rest template is still used in spring security Servlet for oauth2 flow

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

    It's so short comparing to the RestTemplate or WebClient.
    Let's record the video about Open Feign declarative client.

  • @salo.
    @salo. Před 10 měsíci

    Cool... another video without headers examples...exactly as hundreds others on YT.. 18 min of pure water... Really useful

    • @DanVega
      @DanVega  Před 10 měsíci +1

      .header() on uri() or you can add a defaultHeader( ) to the RestClient.builder()

    • @salo.
      @salo. Před 10 měsíci

      @@DanVega thanks for your answer. Will you do the video with custom requests?

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

    Sir i have a question
    I wanted to build a spring book project but i have an issue. I have an author and a book entity. They are related to each other. These 2 are in same microservice. How can i seperate them. I use this rest client but how i related them?

    • @cviniciusm
      @cviniciusm Před 10 měsíci +1

      Microservices doesn't mean a separate service for each entity, microservice is fine tuning services that make sense, thin close instead of wide open. Does make sense a author microservice alone? What is it purpose alone? Book can be managed by a microservice alone, and author be part of this microservice because a book must have one or more authors. I don't think you should separate them. Microservices provides high degree of maintainability, you could manage book and author independent of each other, but as they are close related, the cost to maintain the relationship could be greater than to maintain them separated. Each time you search a book and show it to the user, you must show the names of the authors too, you will not show id's of authors instead, right. If the author is a separated microservice than you will have to make extra call just to get author data each time you search for book or just before you present a book to the user.

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

      @@cviniciusm my author has crud operations only. author - book relation is many to one. I use this in entity.
      I got your idea btw. Thank you very much 🙏

  • @M_Jaggard
    @M_Jaggard Před 11 měsíci +1

    I don't get why anyone would be excited about ANOTHER new HTTP client! There are now hundreds - at least 3 in Spring alone. All because we don't want to use an existing dependency but add it to the more general Spring bloat‽

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

      I am not excited, I am curious. Just use one that fit your project or your company guidelines.