Spring Cloud Feign - Declarative REST Client

Поділитися
Вставка
  • Опубліковано 6 вер 2024
  • This video explain you what is Feign client and how to communicate with other microservice using Feign client
    As we all know We can do micro service communication in many ways. Rest template is widely used approach but there is another approach which is well suited for Micro services which is by using Feign Client. Feign client by default supports client side load balancing by using Ribbon and fault tolerance by using Hystrix.
    GitHub:
    github.com/Jav...
    Blogs:
    javagyanmantra...
    Facebook Group :
    / 919464521471923
    Like & Subscribe

КОМЕНТАРІ • 128

  • @Gautamkumar-ys6hc
    @Gautamkumar-ys6hc Рік тому +2

    Most straightforward explanation. Great Man,Thank you

  • @bantubholenath9515
    @bantubholenath9515 2 роки тому +1

    tq so much bro, really you explained like a friend who explain the ans before 5min exam....

  • @mks5988
    @mks5988 3 роки тому +1

    Play back speed 1.75 is perfect for me.i love ur videos.thanks for ur service

  • @madhusudanratnalu400
    @madhusudanratnalu400 2 роки тому +1

    Bhai tame odia loko ki... 😁
    Mu 100% sure odia loko..
    Bhala explain karucha.. Dhanyabad bhai..

  • @kollarajasekhar6502
    @kollarajasekhar6502 3 місяці тому +1

    Thank You Vey Much, it is very simple and good tutorial

  • @santoshkamat6132
    @santoshkamat6132 3 роки тому +2

    You are a legend bro. Hope you get millions and millions of subscribers

  • @antonyrichard369
    @antonyrichard369 2 роки тому +2

    Very simple and clean explanation !! Thank you

  • @harshitanand8216
    @harshitanand8216 3 роки тому +2

    Your every video is well explained.

  • @VIGNESHGOPAL
    @VIGNESHGOPAL 4 роки тому +4

    Simple and neat. Precise to the point. Thank you bro !

  • @ayyappareddy4461
    @ayyappareddy4461 Рік тому +2

    Thank you sir ...

  • @dimimurik3970
    @dimimurik3970 3 роки тому +1

    Nice! Very good hints about the resources like jsonschema2pojo & jsonplaceholder.

  • @enfieldli9296
    @enfieldli9296 2 роки тому +1

    Most straight foward explanations!

  • @ascar66
    @ascar66 Рік тому +1

    Simple and easy to understand explanation, thank you !

  • @valcmeza
    @valcmeza 3 роки тому +1

    Thank you very much! I thought the process was going to be difficult but you explained it very well!

  • @rakshitfamily
    @rakshitfamily 2 роки тому +2

    Really very very helpful.
    Thank you 😊

  • @nagendirank8010
    @nagendirank8010 3 роки тому +1

    Nice and simple explanation keep it up thanks

  • @techappleteja8564
    @techappleteja8564 4 роки тому +3

    what if rest api i want to use are secured with base auth?

    • @Javatechie
      @Javatechie  4 роки тому

      You need to pass basic auth as part of request header ?
      Do you want me to prepare content on this ?

    • @techappleteja8564
      @techappleteja8564 4 роки тому +1

      Java Techie yes sir please consider do this actually as you know mostly all Indian developers are trying to use strip alternative Razorpay for payments and their api use Base Auth, i tried to use their api by following your feign tutorial and now stuck at this. There no UA-cam tutorial on using razorpay in spring boot projects - thank you for responding

    • @Javatechie
      @Javatechie  4 роки тому

      @@techappleteja8564 okay I will do either stripe or razopay . 👍🏻

  • @arungore6578
    @arungore6578 3 роки тому +1

    Very good ..keep educating us

  • @youglob
    @youglob 3 роки тому +3

    Superb and well explained. Made it very easy to Understand the concept :)

  • @manish.adhikari
    @manish.adhikari 4 роки тому +4

    Hey Basant,
    It is really a helpful tutorial. You are doing a great job! Thanks!
    However after watching the complete tutorial I came across three questions:
    1) How to avoid the hardcoding of microservice endpoint url configured inside the @FeignClient url attribute. As far as I believe annnotation's attribute accepts constant value which needs to be resolved during compile time. We can't make the url hard coded as in future if the microservice endpoint changes we need to make changes at our end as well.
    2) How can we pitch in spring cloud config server in this scenario to take the microservice endpoint from repositories like GIT and rest assure that endpoint changes in future doesn't impact our code?
    3) How is OpenFeign doing load balancing?

    • @mudassirshahzadkk
      @mudassirshahzadkk 4 роки тому +7

      1) Feign Client is usually used with Eureka (Service Discovery) where each microservice has a client id. So, say for a user service, the client id will be "user-service". Now, instead of using the url in the feign client interface, you'll just use the client id and eureka will provide a ready instance of that service. This way, even if the url or port of the service changes, the service still has the client id. So, no impact on the feign client.
      2) There are two approaches when using Spring cloud config with service discovery. Config first and Discovery first. With the Config first approach, you get the service instances from eureka.
      3) Feign uses Ribbon as a load balancer.
      Summary: Eureka provides services instances based on the client id. Ribbon(Comes with Feign) load balances if there are more than one instance of a service. Feign provides implementation at RUNTIME.

    • @manish.adhikari
      @manish.adhikari 4 роки тому +1

      @@mudassirshahzadkk Thanks, that helps!

    • @atulpatil7472
      @atulpatil7472 3 роки тому +1

      @@mudassirshahzadkk thanks. I was reading comments for this only..

    • @mudassirshahzadkk
      @mudassirshahzadkk 3 роки тому +1

      @@atulpatil7472 I'm glad it helped 👍

    • @mudassirshahzadkk
      @mudassirshahzadkk 3 роки тому +1

      @@manish.adhikari I'm glad it helped 👍

  • @AkshayGohilYT
    @AkshayGohilYT 3 роки тому +3

    To the point! Superb! Quick and neat! thanks

  • @ameerm7894
    @ameerm7894 3 роки тому +1

    Good example and well explanation... Please keep it up good work.

  • @rishikesharora8681
    @rishikesharora8681 3 роки тому +2

    Fabulous explanation, all confusion cleared 😍

  • @tanayvartak4362
    @tanayvartak4362 3 роки тому +1

    Thanks... Nice & clear explanation

  • @shivyadav2278
    @shivyadav2278 2 роки тому +1

    Thanks for this tutorial, can you create video to use feign client with jwt token authentication.

  • @AhmedKhaled-he9mf
    @AhmedKhaled-he9mf 2 роки тому +1

    I very love it, you are doing awesome work and learning , thanks very much

  • @arpanbanejee5143
    @arpanbanejee5143 3 роки тому +2

    Thanks for the video! To the point explanation, this is what i was looking for!

  • @huseyinavnikadoglu5541
    @huseyinavnikadoglu5541 4 роки тому +3

    Easy explanation , thanks for that. It could've been more useful if you get the data and put it in a repo. in most cases we use that :)

  • @thalapathis
    @thalapathis 2 роки тому +1

    Clean Explanation. But one doubt. Why you're using OpenFeign?
    We have spring-cloud-starter-feign, right? Is it same implementation?

    • @Javatechie
      @Javatechie  2 роки тому +1

      I used the old version buddy

    • @thalapathis
      @thalapathis 2 роки тому

      @@Javatechie ok. Pls put one more video with version when you have sometime.

  • @danillolf
    @danillolf 3 роки тому +1

    thanks for the video!

  • @SinghHarmanat
    @SinghHarmanat Рік тому +1

    Straight forward...!

  • @azatburkhanov1397
    @azatburkhanov1397 3 роки тому +1

    thank you. really simply explained.

  • @raghurambodapati6769
    @raghurambodapati6769 2 роки тому +1

    super simple and super easy explanation :)

  • @dhayakardhaya8989
    @dhayakardhaya8989 3 роки тому +1

    Hey Man you are just awesome with excellent explanation. Thanks for every video

  • @tewodroskasahun8721
    @tewodroskasahun8721 2 роки тому +1

    You are amazing. It was super helpful.Thank you very much

  • @vihariv3829
    @vihariv3829 3 роки тому +1

    very good sir... im fan of you

  • @awesomearts252
    @awesomearts252 Рік тому +1

    Thank you so much

  • @TheFrediee
    @TheFrediee Рік тому

    Nice tutorial, Thanks. Can you also make video how to access rest service on oauth2 using feign client.

  • @arfin97
    @arfin97 4 роки тому +1

    Awesome, Learned a lot along with the actual topic form this video. Thanks dude.

  • @kambalavijay6800
    @kambalavijay6800 3 роки тому +1

    Simply at best buddy

  • @nisal2469
    @nisal2469 2 роки тому +1

    Thank you ♥️

  • @maheshd3506
    @maheshd3506 3 роки тому +1

    Simple and clear, thanks

  • @farukciber9302
    @farukciber9302 5 років тому +2

    Great explanation, this helps a lot. Thank you

  • @siddhantsrivastava4048
    @siddhantsrivastava4048 3 роки тому +1

    Hi, Please don't add any extra dependency, which is not needed like devtool, Lombok. Your project will work fine without this too. If anyone facing issue, please comment. Ready to help.

    • @Javatechie
      @Javatechie  3 роки тому

      Siddhant there is reason to add these dependency .
      You should know the purpose of using this dependency .

  • @Saravanan-lj9so
    @Saravanan-lj9so 4 роки тому +1

    You are doing a great job! Thanks!

  • @muthukumarparamasivam8893
    @muthukumarparamasivam8893 4 роки тому +1

    Great explanation. can you please update how feign works with load balancer?

  • @franciscageorgue2207
    @franciscageorgue2207 3 роки тому +1

    Nice explanation, Thank you a lot!

  • @Srini8174
    @Srini8174 3 роки тому +1

    Please explain distributed transaction in micro services communication with example

  • @manasdeora4601
    @manasdeora4601 3 роки тому +1

    Very nice and accurate.

  • @joestasebolela1889
    @joestasebolela1889 3 роки тому +1

    Nice and clean.

  • @Biduro.1992
    @Biduro.1992 4 роки тому +1

    @ if you need to pass header information while invoking rest api does feign clients supports.
    Ideally it should be inter service micro services communications

    • @Javatechie
      @Javatechie  4 роки тому

      Yes it support that is how we are passing authentication header right

  • @techlearn207
    @techlearn207 3 роки тому

    Simple and neat. thanks Brother.

  • @sasi2182
    @sasi2182 6 років тому +1

    Nice explaination... Basant

  • @Crane_FISH
    @Crane_FISH 3 роки тому

    Feign is for external app accessing our micro service's api
    Or
    One micro services accessing another micro services api of same application....

  • @tusharverma4507
    @tusharverma4507 3 роки тому +1

    Thanks a lot buddy :)

  • @aldroid5838
    @aldroid5838 Рік тому

    Since i use rest template where i configure ssl cert for https connection,how can i achieve same here?

  • @GauravSharma-wb9se
    @GauravSharma-wb9se 4 роки тому +3

    you haven't shown load balancing here, how it will happnen ?

  • @kishordige9721
    @kishordige9721 Рік тому

    Thank you!

  • @petyapetrova9956
    @petyapetrova9956 Рік тому +1

  • @prakhardubey24
    @prakhardubey24 3 роки тому

    please describe those four classes in short which we directly download i.e., address, userResponse...

  • @TheFashionsketcher
    @TheFashionsketcher 3 роки тому +1

    very nice tutorial! However, in some endpoints that contain "/api/", return 403 in my case and I don't have any security stuff on. Do you know why is that?

    • @Javatechie
      @Javatechie  3 роки тому

      Please share source code with github

    • @TheFashionsketcher
      @TheFashionsketcher 3 роки тому

      @@Javatechie github.com/bwielk/spring-jgiven-selenium-feign - there are two clients in the project and if you run the tests for the second one, you'll see I get 403 whereas I can access the endpoint with no issues visa the browser. Thanks!

  • @nitishjoshi_
    @nitishjoshi_ 3 роки тому +1

    Hi I am getting a bean not found error, how and where should I add the bean for FeignClient? Please Reply

    • @Javatechie
      @Javatechie  3 роки тому

      Did you wrote @EnableFeignClient annotation in main class

  • @tandomaliwa3212
    @tandomaliwa3212 5 років тому +1

    Awesome, so basic!

  • @gopald7263
    @gopald7263 6 років тому +1

    Awesome..

  • @gurupadamgundala5142
    @gurupadamgundala5142 6 років тому +1

    Awesome

  • @devashishsrivastava1132
    @devashishsrivastava1132 4 роки тому +1

    Thanks. I find this very helpful. But I'm struggling when I try to POST using feign client. Can you help me with that?

    • @Javatechie
      @Javatechie  4 роки тому +1

      Could you please mention your problem

    • @devashishsrivastava1132
      @devashishsrivastava1132 4 роки тому +1

      @@Javatechie I've figured out the issue. I was missing one of the annotations. Thanks for the offer to help.

  • @riteshvish123456
    @riteshvish123456 4 роки тому +1

    good job!

  • @farukciber9302
    @farukciber9302 5 років тому

    How would get the response body and headers with a post request to an endpoint which returns a json body? Assuming I have the Dto for both request body and response body. Is responseentity a good return type ?

    • @Javatechie
      @Javatechie  5 років тому

      Yes it's generic and standard approach to follow ResponseEntity

  • @nivz93
    @nivz93 5 років тому +1

    URL is not getting mapped.
    Can you tell me where I must have gone wrong?
    Following are the logs:
    2019-01-17 15:53:26.820 INFO 64907 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
    2019-01-17 15:53:27.130 INFO 64907 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$e870aa65] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    . ____ _ __ _ _
    /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
    ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
    \\/ ___)| |_)| | | | | || (_| | ) ) ) )
    ' |____| .__|_| |_|_| |_\__, | / / / /
    =========|_|==============|___/=/_/_/_/
    :: Spring Boot :: (v2.1.2.RELEASE)
    2019-01-17 15:53:27.246 INFO 64907 --- [ restartedMain] c.d.s.feign.api.SpringFeignApplication : No active profile set, falling back to default profiles: default
    2019-01-17 15:53:28.216 INFO 64907 --- [ restartedMain] o.s.cloud.context.scope.GenericScope : BeanFactory id=4bfd80a1-2eb0-317e-9c6c-ec9aa2820460
    2019-01-17 15:53:28.326 INFO 64907 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$e870aa65] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2019-01-17 15:53:28.878 INFO 64907 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
    2019-01-17 15:53:28.903 INFO 64907 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
    2019-01-17 15:53:28.903 INFO 64907 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.14]
    2019-01-17 15:53:28.913 INFO 64907 --- [ restartedMain] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/n0d00eb/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
    2019-01-17 15:53:29.008 INFO 64907 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
    2019-01-17 15:53:29.008 INFO 64907 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1726 ms
    2019-01-17 15:53:29.257 INFO 64907 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
    2019-01-17 15:53:29.293 WARN 64907 --- [ restartedMain] o.s.c.n.a.ArchaiusAutoConfiguration : No spring.application.name found, defaulting to 'application'
    2019-01-17 15:53:29.296 WARN 64907 --- [ restartedMain] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
    2019-01-17 15:53:29.296 INFO 64907 --- [ restartedMain] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
    2019-01-17 15:53:29.301 WARN 64907 --- [ restartedMain] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
    2019-01-17 15:53:29.301 INFO 64907 --- [ restartedMain] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
    2019-01-17 15:53:29.471 INFO 64907 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
    2019-01-17 15:53:29.786 INFO 64907 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
    2019-01-17 15:53:29.788 INFO 64907 --- [ restartedMain] c.d.s.feign.api.SpringFeignApplication : Started SpringFeignApplication in 3.525 seconds (JVM running for 3.993)

    • @Javatechie
      @Javatechie  5 років тому

      Hi Nivedita, in spring Boot version 2.1.1 onwards URL mapping won't display on console.its kind of bug .so just ignore it and hit your URL it will work no doubt

    • @nivz93
      @nivz93 5 років тому +1

      @@Javatechie Thanks!

  • @ankitgupta-sp9yt
    @ankitgupta-sp9yt 4 роки тому +1

    Thanks. Appreciate your efforts :)

  • @sudhanshugera6690
    @sudhanshugera6690 4 роки тому +1

    Can we consume soap using feign client?

    • @Javatechie
      @Javatechie  4 роки тому

      No we can't use it to consume soap webservices
      You can use WebservicesTemplate. Better checkout my soap webservices consumer video

  • @yavuzbahadr6700
    @yavuzbahadr6700 4 роки тому +1

    ok, thanks :)

  • @kushalbaldev8490
    @kushalbaldev8490 6 років тому

    Could you explain more in detail I understood you wrote a controller and there you wrote @enablefeignclient
    There you wrote one method getallusers and from there you called the method which you worte under / user
    Actually I don't understand how it internally works getall users is defined where?
    You have used a fake api to call but how the url is actually formed in a way to call the request please if you can guide me it would be helpful.

    • @santoshkumarpalli7597
      @santoshkumarpalli7597 5 років тому

      Very helpful Brother. Thank you very much. could you please upload the video for feign client with post method please

  • @sushilkumarpandeypandey1087
    @sushilkumarpandeypandey1087 5 років тому

    how this is supporting load balancing can you explain in detail

  • @jugadusakshi3211
    @jugadusakshi3211 4 роки тому +1

    Hey how to access api if it has username and password, using feign client in spring boot

    • @Javatechie
      @Javatechie  4 роки тому +1

      You need to pass authentication header to feign client

    • @jugadusakshi3211
      @jugadusakshi3211 4 роки тому

      How to pass that, please help me in this..

    • @Javatechie
      @Javatechie  4 роки тому +1

      @@jugadusakshi3211 please go through below link stackoverflow.com/questions/39606744/how-to-consume-basic-authentication-protected-restful-web-service-via-feign-clie

    • @jugadusakshi3211
      @jugadusakshi3211 4 роки тому +1

      Thanks you so much 😁

  • @ariel_alves_dutra
    @ariel_alves_dutra 3 роки тому

    Thanks man!

  • @SamirKumar-yv6cr
    @SamirKumar-yv6cr 4 роки тому +1

    Thankyou very much Basant for awesome videos.
    Can you tell how to implement Centralised jwt based spring security for my different micro services

    • @Javatechie
      @Javatechie  4 роки тому +1

      Yes am planning to do that , it's in my list
      You need to handle it in API gateway .

    • @SamirKumar-yv6cr
      @SamirKumar-yv6cr 4 роки тому +1

      @@Javatechie thankyou very much for the hint

  • @veronicalima5664
    @veronicalima5664 2 роки тому

    Valeu!

  • @arpanbanejee5143
    @arpanbanejee5143 3 роки тому

    When i treid to set it up in local i am getting this error, can u pls help me out . I am getting this error while running the application
    Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.properties.ConfigurationPropertiesBean
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
    ... 35 common frames omitted

    • @arpanbanejee5143
      @arpanbanejee5143 3 роки тому

      the src/main/resources folder is not present in your github repo, it seems it lacks some configuration

    • @arpanbanejee5143
      @arpanbanejee5143 3 роки тому +1

      Its working now, the cloud version was not working with the spring boot version in my case, i changed them

    • @Javatechie
      @Javatechie  3 роки тому +1

      Yup we need to use same cloud version as per spring starter parent

  • @gennadyshevchenko7940
    @gennadyshevchenko7940 4 роки тому

    how can I fetch big volume of data with feign client?

    • @Javatechie
      @Javatechie  4 роки тому

      Volume doesn't matter in any of rest client that need to be handle from provider section
      If still you want to implement in client side then you may need to implement multithreading or chunk basic
      But as per my experience I never faced any issue while fetching large volume of data using feign.

  • @Pratapsingh-mt9cu
    @Pratapsingh-mt9cu 5 років тому +1

    bro i already saw ur almost all the video related to the boot, cloud and micro but how will handle the exception through the feign

    • @Javatechie
      @Javatechie  5 років тому

      Feign is not meant for exception handling.but if you are using feign client then we can handle the exception the way we are doing in Rest template

  • @namanmandli
    @namanmandli 6 років тому +1

    Teaching is a technique and I can see it from you.....

    • @namanmandli
      @namanmandli 6 років тому

      Can you PLEASE provide a tutorial on OAuth2?

  • @SivaKumar-mo9uj
    @SivaKumar-mo9uj 4 роки тому +1

    Bad coding practice

    • @Biduro.1992
      @Biduro.1992 4 роки тому

      Could you please tell what is the wrong coding practices followed here.

    • @SivaKumar-mo9uj
      @SivaKumar-mo9uj 4 роки тому +1

      @@Biduro.1992 As per coding standards, rest-controller code has to be written in separate class. It should not be combined in springbootapplication class. Many of the freshers are fallowing you. So request you to fallow coding guidelines, that will be helpful. Thanks for providing the video on feignclient.

    • @Javatechie
      @Javatechie  4 роки тому

      Hi shiva going forward I will take care

  • @Readdeo
    @Readdeo 2 роки тому

    This is horrible.

  • @liferayasif9382
    @liferayasif9382 3 роки тому +1

    so simple and clean, thanks