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
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?
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.
@ if you need to pass header information while invoking rest api does feign clients supports. Ideally it should be inter service micro services communications
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.
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 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!
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)
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
@@jugadusakshi3211 please go through below link stackoverflow.com/questions/39606744/how-to-consume-basic-authentication-protected-restful-web-service-via-feign-clie
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 ?
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.
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
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.
@@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.
Most straightforward explanation. Great Man,Thank you
tq so much bro, really you explained like a friend who explain the ans before 5min exam....
Play back speed 1.75 is perfect for me.i love ur videos.thanks for ur service
You are a legend bro. Hope you get millions and millions of subscribers
Your every video is well explained.
Thank you very much! I thought the process was going to be difficult but you explained it very well!
Nice and simple explanation keep it up thanks
Very simple and clean explanation !! Thank you
Simple and easy to understand explanation, thank you !
Nice! Very good hints about the resources like jsonschema2pojo & jsonplaceholder.
Superb and well explained. Made it very easy to Understand the concept :)
Simple and neat. Precise to the point. Thank you bro !
Fabulous explanation, all confusion cleared 😍
Good example and well explanation... Please keep it up good work.
Very good ..keep educating us
Most straight foward explanations!
I very love it, you are doing awesome work and learning , thanks very much
Valeu!
Really very very helpful.
Thank you 😊
Hey Man you are just awesome with excellent explanation. Thanks for every video
Thanks buddy 😊
Thanks... Nice & clear explanation
Awesome, Learned a lot along with the actual topic form this video. Thanks dude.
Thanks for the video! To the point explanation, this is what i was looking for!
Thank You Vey Much, it is very simple and good tutorial
To the point! Superb! Quick and neat! thanks
thank you. really simply explained.
You are amazing. It was super helpful.Thank you very much
what if rest api i want to use are secured with base auth?
You need to pass basic auth as part of request header ?
Do you want me to prepare content on this ?
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
@@techappleteja8564 okay I will do either stripe or razopay . 👍🏻
Bhai tame odia loko ki... 😁
Mu 100% sure odia loko..
Bhala explain karucha.. Dhanyabad bhai..
😂😂 dhanyabad 😀
super simple and super easy explanation :)
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 :)
very good sir... im fan of you
Great explanation, this helps a lot. Thank you
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?
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.
@@mudassirshahzadkk Thanks, that helps!
@@mudassirshahzadkk thanks. I was reading comments for this only..
@@atulpatil7472 I'm glad it helped 👍
@@manish.adhikari I'm glad it helped 👍
Clean Explanation. But one doubt. Why you're using OpenFeign?
We have spring-cloud-starter-feign, right? Is it same implementation?
I used the old version buddy
@@Javatechie ok. Pls put one more video with version when you have sometime.
Nice explaination... Basant
@ if you need to pass header information while invoking rest api does feign clients supports.
Ideally it should be inter service micro services communications
Yes it support that is how we are passing authentication header right
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.
Siddhant there is reason to add these dependency .
You should know the purpose of using this dependency .
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?
Please share source code with github
@@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!
You are doing a great job! Thanks!
Thank you sir ...
Since i use rest template where i configure ssl cert for https connection,how can i achieve same here?
Nice explanation, Thank you a lot!
so simple and clean, thanks
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)
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
@@Javatechie Thanks!
Thank you ♥️
Thanks for this tutorial, can you create video to use feign client with jwt token authentication.
Hi I am getting a bean not found error, how and where should I add the bean for FeignClient? Please Reply
Did you wrote @EnableFeignClient annotation in main class
Great explanation. can you please update how feign works with load balancer?
Hi Muthu , I will do
Please explain distributed transaction in micro services communication with example
please describe those four classes in short which we directly download i.e., address, userResponse...
Thank you so much
Simple and neat. thanks Brother.
Nice tutorial, Thanks. Can you also make video how to access rest service on oauth2 using feign client.
you haven't shown load balancing here, how it will happnen ?
Use ribbon client
Can we consume soap using feign client?
No we can't use it to consume soap webservices
You can use WebservicesTemplate. Better checkout my soap webservices consumer video
Thanks. I find this very helpful. But I'm struggling when I try to POST using feign client. Can you help me with that?
Could you please mention your problem
@@Javatechie I've figured out the issue. I was missing one of the annotations. Thanks for the offer to help.
thanks for the video!
Hey how to access api if it has username and password, using feign client in spring boot
You need to pass authentication header to feign client
How to pass that, please help me in this..
@@jugadusakshi3211 please go through below link stackoverflow.com/questions/39606744/how-to-consume-basic-authentication-protected-restful-web-service-via-feign-clie
Thanks you so much 😁
how this is supporting load balancing can you explain in detail
Simply at best buddy
Feign is for external app accessing our micro service's api
Or
One micro services accessing another micro services api of same application....
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 ?
Yes it's generic and standard approach to follow ResponseEntity
Very nice and accurate.
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.
Very helpful Brother. Thank you very much. could you please upload the video for feign client with post method please
Thanks a lot buddy :)
❤
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
the src/main/resources folder is not present in your github repo, it seems it lacks some configuration
Its working now, the cloud version was not working with the spring boot version in my case, i changed them
Yup we need to use same cloud version as per spring starter parent
how can I fetch big volume of data with feign client?
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.
Nice and clean.
Thank you!
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
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
ok, thanks :)
Awesome, so basic!
Thankyou very much Basant for awesome videos.
Can you tell how to implement Centralised jwt based spring security for my different micro services
Yes am planning to do that , it's in my list
You need to handle it in API gateway .
@@Javatechie thankyou very much for the hint
Thanks. Appreciate your efforts :)
Awesome
Awesome..
Teaching is a technique and I can see it from you.....
Can you PLEASE provide a tutorial on OAuth2?
good job!
Thanks man!
Bad coding practice
Could you please tell what is the wrong coding practices followed here.
@@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.
Hi shiva going forward I will take care
This is horrible.
Straight forward...!
Simple and clear, thanks