Dynamic config with spring Boot - Microservice configuration with Spring Boot [13]

Sdílet
Vložit
  • čas přidán 7. 09. 2024

Komentáře • 106

  • @maurov2104
    @maurov2104 Před 3 lety +14

    December 2020: After Spring Boot 2.4.0/Spring Cloud 2020.0.0-M5 you need to include the spring-cloud-starter-bootstrap dependency and create a bootstrap.yml with the spring application name, spring cloud config uri and the management endpoints web exposure include property there

    • @aaronasuncion4815
      @aaronasuncion4815 Před 3 lety +3

      No need, remove dependency 'spring-cloud-starter-bootstrap', and replace 'spring.cloud.config.uri' with 'spring.config.import'.

    • @tonegrail650
      @tonegrail650 Před rokem

      @@aaronasuncion4815 When I do that I get java.lang.IllegalStateException: Unable to load config data from 'localhost:8888'

    • @uvinweththasinghe9232
      @uvinweththasinghe9232 Před rokem

      Thanks man!

  • @easwargaming7903
    @easwargaming7903 Před 4 lety +24

    Now i can mention i know microservices in my resume😂 Great Thanks Kaushik.

    • @easwargaming7903
      @easwargaming7903 Před 4 lety +19

      @ninuxy Huh I don't really give my resume to the dumb who doesn't know what is "Sarcasm".

    • @kaushalmzp
      @kaushalmzp Před 4 lety

      same here ;)

    • @jonsnow9246
      @jonsnow9246 Před 4 lety +1

      @@easwargaming7903 @ninuxy Ohhhhhhhhhhhh

  • @gauravmam
    @gauravmam Před 4 lety +1

    Thanks a lot Kaushik. There are materials and tutorials everywhere but the depth and details of understanding the concepts that I get here are simply amazing.

  • @nautilus2024
    @nautilus2024 Před rokem +2

    I think restart microservice is better choice. If we use accuator and @RefreshScope, it have 2 drawbacks: (1) accuator open some hookup API which might lead to security concern. (2) @RefreshScope impact performance a lot. All instances that use the config bean need to refresh ALL of its dependencies, not just the config bean.

  • @royalvivek9224
    @royalvivek9224 Před 4 lety +1

    Hey kaushik.... Because of you so many things are easy to learn.... Many many thanks to you make a wonderful video and make a easy to work in It industry.. 🙏🙏🙏🙏🙏

  • @PrasannaLakshmi74
    @PrasannaLakshmi74 Před 4 lety +4

    Simply superbly revealed...😃

  • @mirogula
    @mirogula Před 4 lety

    This is really convoluted. Thank god for good old JMX MBeans.

  • @udit9337
    @udit9337 Před 4 lety

    God explanation looks simple and easy to understand recommended to everyone to check this out

  • @ohhhgggeeezzz
    @ohhhgggeeezzz Před 3 lety +3

    Strange..... @9:54 I see "config.client.version". but the key "my.greeting" is not showing up. If I delete my spring-boot.config.yml and just use the default everything works. But If I have specific microservice config file.... things don't get udated. Anyone experiencing the same problem?

  • @pavanmodi7265
    @pavanmodi7265 Před 3 lety

    Really it's very useful, spring cloud configuration,thanks to provide this kind of knowledge 🙏🙏

  • @SunilVerma-gr7yv
    @SunilVerma-gr7yv Před 4 lety +1

    Thanks Kousik it is really helping me simple and best.

  • @sameerpande7567
    @sameerpande7567 Před 3 lety +2

    The refresh scope is not working with microservice.yml file. It worked with application.yml

    • @Asinha1010
      @Asinha1010 Před 3 lety

      Hey you're right. I ran into the same problem. Were you able to make it work with microservice.yml

  • @anshulsatish
    @anshulsatish Před 4 lety +4

    Hi Koushik, As you mentioned in the video could you please help us with the git tutorial which covers most of the use cases, especially reverting a merge request, solving merge conflict, and switching over branches without committing(branch specific or unmerged changes).

  • @yevgeny3985
    @yevgeny3985 Před 2 měsíci

    Great videos, what is the best practice to automate refresh without using rest calls?

  • @mohammedshabbirahmed976

    You are Awesome Bro You are A Hero You ROCK THE WORLD BRO YOU ARE SUPER AND THE BEST

  • @email2krish1
    @email2krish1 Před 4 lety

    Hi Koushik I am going to watch this end to end

  • @AleksandarT10
    @AleksandarT10 Před rokem +1

    How would you refresh properties in a Microservice based environment? Like when there are X amount of servers running - and possible them being behind a LoadBalancer

  • @Aapla_Institute
    @Aapla_Institute Před 4 lety +2

    hi kaushik i am eagrly waiting for API GateWay ,kindly upload asap

  • @romantsyupryk3009
    @romantsyupryk3009 Před 4 lety +1

    Thanks so much for this tutorial.

  • @mohdfurkan2062
    @mohdfurkan2062 Před 4 lety +3

    Hi Koushik, Thanks for the informative video.
    I am watching microservices end to end.
    I have two questions.
    1. In case of dynamic configure, We need to refresh actuator, It means if multiple instances are running with a different port, we have to refresh all of those?
    2. In case of having YML files named as microservices, how to implement environments based configuration. It is like -environment?

    • @hidayatrzayev6603
      @hidayatrzayev6603 Před 3 lety

      @Uday Kumar Bommala Thank you for sharing!

    • @akshaygupta2863
      @akshaygupta2863 Před 2 lety

      Hi, Have you find out the solution of this refresh api ...how can we do it one go or can we make it push end point instead of pull end point

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

    @javabrains Hey Kaushik, if the config values are used at multiple places, say many service classes,
    As per the video, do we need to add @RefreshScope in all the places ? Request you to help us in that usecase

  • @StyleTrick
    @StyleTrick Před 4 lety +7

    Is there a good way to automate sending the POST request after making changes to the config server? Perhaps through Jenkins or something of that nature.

    • @stas4985
      @stas4985 Před 3 lety

      it's easy enough to write it yourself

    • @hidayatrzayev6603
      @hidayatrzayev6603 Před 3 lety +3

      @@stas4985 yes, but what if I have dozens of microservices than need to get the updated values? I don't wanna be sitting there and sending those POST requests to each and every of them.

  • @rossxie9809
    @rossxie9809 Před 3 lety +1

    is there security control over who can call the refresh end point?

  • @basavaraj2065
    @basavaraj2065 Před rokem

    When there all multiple microservices belong to same group and you call actuator/refresh POST call, it could only hit one of the instance and refresh. What about all other instances ?

  • @SanthoshkumarNagulanchi

    Can you please explain how to refresh all pods in a service?

  • @atulsharma8596
    @atulsharma8596 Před 4 lety +2

    Hi Koushik,
    Content is priceless. I have following two questions.
    1. What should be the name of yml-file for the specific profile (not only for the specific microservice, but also profile)?
    2. Do we have any workaround for refreshing 100's of micro-services in a go once the application.yml on git repo is updated?
    Thanks for sharing this amazing content with us.

  • @elephant742
    @elephant742 Před 4 lety +4

    Hi Kaushik,
    Nice video series. It was really helpful. I have couple of questions -
    1. Is it a good practice to rely on Version control for config management as I have read almost everywhere that pushing credentials to git is a bad practice/security issue. I know i can make the repo private but is it still a good solution ?
    2. Say we have DB properties defined in spring cloud config server. Admin updates the DB properties and at the same time a DB operation is running on the micro service side. How do we ensure that the change of DB properties does not affect the ongoing operation ?
    3. Doesn't spring cloud config server create a bottleneck ? If the server is down, won't the other micro services be affected ?

    • @diwaygrover
      @diwaygrover Před 4 lety +2

      Hi Dev
      Here are answers to your questions from my experience. I am not sure if it 100% correct, but hoping it helps.
      1. No, it is not a good practice to store credentials on git repo even if it is private. You should use some vault to store passwords, e.g. Spring Cloud Vault, AWS Secret Manager
      2. As per the Kaushik's video, you need to hit the actuator endpoint for the config properties to get refreshed in the microservice. Also, if you are running any DB operation on the microservice, you should business logic in a way that if your transaction doesn't get committed , it should rollback.
      3. Yes it may do depending on the situation. Suppose server is running and you started 2 microservices, so these microservices will fetch and cache all the configs. Now the server goes down so those microservices won't be affected, but if now you are starting up a 3rd microservice, it won't be able to fetch config from server. So instead that 3rd microservice will fetch configs from its JAR, if it is present.

  • @elangopadmanabhan9920
    @elangopadmanabhan9920 Před 3 lety +2

    Hi , I have a doubt on that @RefershScope. As you say , in our application perspective we are having n number of controller and we are using so many value from the property files. At that if we update the changes in cloud config server, we need to add the @RefershScope in each and every controller. If that is the case then , it will not be nice as we are going to add in 100's of controller if we are having it. Is there any other alternative , like if we want to use it for a entire application, configure it in a place and let all the get uploaded?

  • @chandrasekharreddyp
    @chandrasekharreddyp Před 2 lety +1

    question: in case i have multiple micro services instances for my service, then how do you call /refresh, because if we have 5 instances then though you call /refresh it calls only one instance.
    any idea whats the solution for this use case??

  • @isidme
    @isidme Před 4 lety

    OMG this is so awesome. No polling

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

    I am not able to get it to work. When I run the actuator refresh endpoint, it returns me with an empty array - [] in response. Using the latest version of Springboot - v3.2.3 with spring cloud version - 2023.0.0

  • @ekaterinagalkina7303
    @ekaterinagalkina7303 Před 4 lety +4

    And what should be the name of yml-file for the specific profile (not only for the specific microservice, but also profile)?

  • @shraddhachitalia8391
    @shraddhachitalia8391 Před 2 lety

    Amazing course !!

  • @sajip7064
    @sajip7064 Před 4 lety

    Please add a slide to automate dynamic refresh also as it is not advisable to call the post method to refresh manually.

  • @OlegPetrow-ze6ft
    @OlegPetrow-ze6ft Před 2 lety

    Thanks a lot! It was really helpful!

  • @vishalpoddar
    @vishalpoddar Před rokem

    don't forget to add management.endpoints.web.exposure.include=* in application.properties

  • @thilinakalummoragoda8597
    @thilinakalummoragoda8597 Před 4 lety +1

    Good one. Thanks 💝💝

  • @nadalnguyen4951
    @nadalnguyen4951 Před 3 lety +1

    Kaushik, your videos are awesome, much thanks. For my project, I noticed that dynamic updates only work for my microservice with respect to properties defined in the config server application.yml and not for propeties defined in the microservice specific yml file. I wonder if this is a known issue or perhaps there's something not configured correctly in my setup.

  • @jagadishtembhe1806
    @jagadishtembhe1806 Před 4 lety

    Hi Koushik, Very nicely explained . i like all your videos and that helps a lot to grab concept. Great work you are doing.
    I have one question . In microservice architecture when to use application.yml and when to use bootstrap.yml and which properties goes in which file ...

  • @tomknud
    @tomknud Před 2 lety

    Nice vid, good work, thanks.

  • @antorodrigo2084
    @antorodrigo2084 Před 3 lety

    Hi Kaushik,
    I am searching for the following two things. Let me know if you can help with this.
    1. Lazy initialization of spring security configuation. I'm using OAuth + OpenId. The issuer URI is loaded in DB at some time via CRUD by admin in the same spring boot app. Then only I need to initialize the spring security configure().
    2. Also I want to know how reload the spring security configuration at runtime when the Issuer URI changed at db.

  • @abhishekramkumar8875
    @abhishekramkumar8875 Před 3 lety

    hey I tried everything shown in the tutorial but my bean is not refreshed , besides when i do a post on /actuator/refresh i get in empty [] response wondering what could be the issue

  • @it_qasqyr5865
    @it_qasqyr5865 Před rokem

    Hi. Is it possible to make auto-refresh properties for Spring Cloud clients in a multi-pod environment?

  • @BilalIssa
    @BilalIssa Před 3 lety

    What is the best practice for not so simple properties configuration? e.g. properties for thread pool size etc.

  • @alphaamadoubalde2822
    @alphaamadoubalde2822 Před 2 lety

    Hello when I add the Config Client dependency in my microservice project it refuses to start returning the following error:
    Add a spring.config.import=configserver: property to your configuration.
    If configuration is not required add spring.config.import=optional:configserver: instead.
    To disable this check, set spring.cloud.config.enabled=false or
    spring.cloud.config.import-check.enabled=false.
    I need help

  • @bernardamofah4524
    @bernardamofah4524 Před 3 lety

    @JavaBrains how does the refresh work with versioning. For example wanting to refresh app properties 1.0 to 2.0

  • @vinodmehta5860
    @vinodmehta5860 Před 3 lety

    Hello Kaushik , thanks for nice tutorial. I have one question. how we can handle the scenario if our git repo goes down for some time. Looking forward to your answer
    Thank you

  • @godwinsamuel9821
    @godwinsamuel9821 Před 3 lety +1

    This doesn't work if you are running multiple instance.

    • @subbunittala2012
      @subbunittala2012 Před 3 lety

      Please use spring cloud bus

    • @shraddhachitalia8391
      @shraddhachitalia8391 Před 2 lety

      @@subbunittala2012 can you share any example using cloud bus + rabbitmq/kafka ? I have tried this, however I am using local git and when I invoke /monitor endpoint on config server from postman to mimiic a webhoook, I see `RefreshListener : Received remote refresh request.
      2022-04-28 20:12:39.145 INFO 90782 --- [nio-8888-exec-9] o.s.cloud.bus.event.RefreshListener : Keys refreshed []` :(

  • @satyamramawat
    @satyamramawat Před 3 lety +2

    Hi Koushik,
    Whenever I tries giving a call actuator/refresh it gives me HTTP Status 404 error. Even though all the endpoints are enable. What's the cause of this?

  • @tapajyotigiri
    @tapajyotigiri Před 3 lety

    Hello , how to refresh the client using a Kafka and create a webhook from git to Kafka

  • @mohanbabu9181
    @mohanbabu9181 Před 4 lety +1

    I updated my resume to I have 3 years exp in microservices

  • @user-rg3kj7xy8b
    @user-rg3kj7xy8b Před 7 měsíci

    i am facing issue with database configuration if apply refresh scope. for me even both database URL and r2bc configs, message are changing in refresh scope , i am getting only updated message but my service still pointing to the old Database not the Updated one.
    how can we achieve that one dynamic db connection.

  • @HimanshuSingh_92
    @HimanshuSingh_92 Před 3 lety

    Hi.. I had a question..
    Are we going to add @RefreshScope on top of all beans to take latest prop file values?

  • @akshay-md4fy
    @akshay-md4fy Před 3 lety

    How value will be reflected if we have multiple client instances

  • @Azyro777
    @Azyro777 Před 3 lety

    Is it normal when I edited the spring-boot-config.yml without committing, but the config server output is displaying my edited config. If it is, then what's the use of git repo?

  • @Sukhbir_Ghangas
    @Sukhbir_Ghangas Před 2 lety

    actuator/refresh returns updated value from application.properties file but it is not refreshing the values from microservice specific file. I am using Spring Cloud version 2021.0.4 Please suggest.

    • @Sukhbir_Ghangas
      @Sukhbir_Ghangas Před 2 lety +1

      I have found the solution: I just renamed the application.yml file to bootstrap.yml (inside the client spring boot project) and it started working. Actuator started fetching the updated value from the microservice specific file.

    • @tonegrail650
      @tonegrail650 Před rokem

      @@Sukhbir_Ghangas Thank you! That worked!

  • @tanumoymajumdar874
    @tanumoymajumdar874 Před 3 lety

    Hi, can we have ribbon load balancing servers list dynamically from git ? Let say we have 3 instances initially, based on the load we want to increase it to 5. Can we do this with this approach on the fly ? If we can, then which URL we need to hit to refresh as there are three instances are running. Please guide me on this.

  • @hyperborean72
    @hyperborean72 Před 4 lety

    Thank you so much

  • @buichitai6072
    @buichitai6072 Před 4 lety +1

    I am getting the error "This application has no explicit mapping for /error, so you are seeing this as a fallback" after adding @RefreshScope to the Greeting Controller. When I remove @RefreshScope, I can access the link localhost:8080/greeting normally

    • @RanjithKumar-qj9mn
      @RanjithKumar-qj9mn Před 4 lety

      check you have this in your yaml or properties file --> management.endpoints.web.exposure.include=*

    • @vasusharma1884
      @vasusharma1884 Před 3 lety

      Facing the same issue.

  • @rakshithsirigeri1903
    @rakshithsirigeri1903 Před 3 lety

    Can we use this method for Spring Boot deployed on kubernetes? I mean can configmaps be reloaded using this method?

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

    nice

  • @ikomangmahendra
    @ikomangmahendra Před 3 lety

    Thanks 👍

  • @dowlathbashag65
    @dowlathbashag65 Před 4 lety

    Kaushik, I have an query regarding dynamic config....as per video we need to do 3 steps . 1. actuator dependency added in pom.xml 2. add annotation @RefreshScope in resource bean class 3. test in post man as localhost:8080/actuator/refresh via post method then will refresh the client code. Here my query is if i have 50 microservices and updated config file ...as per above steps we need to test 50 times in the post man call after the refresh or test in the 50 microservice clients or ...please could suggest / clarify me on this. Thanks.

    • @akshaygupta2863
      @akshaygupta2863 Před 2 lety

      Hi, Have you find out the solution for this? Can we make it push endpoint instead of pull endpoint?

  • @prasadpardeshi587
    @prasadpardeshi587 Před 4 lety

    Hi Koushik Kindly help to share Git repo link

  • @kusumarajuprasanth5736

    if we have more than one instance of the same microservice, do we need manually refresh each and every service or do we have any other best alternative to do so ?

  • @USONOFAV
    @USONOFAV Před 4 lety

    Can I use this with CommandLineRunner?

  • @ravichandar6975
    @ravichandar6975 Před 4 lety

    Is this similar to spring cloud Bus

  • @bathulanagendra4621
    @bathulanagendra4621 Před 4 lety

    Hi sir,can we use this technique for monolithic application in springboot.

  • @jackbourner7965
    @jackbourner7965 Před 4 lety

    Not sure this is a production ready mechanism. Requiring a tool to post a request to your application isn’t ideal. I guess you could add an auto refresh class which posts every 10 minutes to config application

    • @sudheepkrishnanm7663
      @sudheepkrishnanm7663 Před 4 lety

      What is the advantage of join sport from subscription ?

    • @shraddhachitalia8391
      @shraddhachitalia8391 Před 2 lety

      @Uday Kumar Bommala Do you have any working example for this? I have tried this, however I am using local git and when I invoke /monitor endpoint on config server from postman, I see `RefreshListener : Received remote refresh request.
      2022-04-28 20:12:39.145 INFO 90782 --- [nio-8888-exec-9] o.s.cloud.bus.event.RefreshListener : Keys refreshed []`

    • @akshaygupta2863
      @akshaygupta2863 Před 2 lety +1

      @@shraddhachitalia8391 Hi, have you find out the solution for this? Like how can we get rid off calling/refresh api every time

  • @AjayKumar-fd9mv
    @AjayKumar-fd9mv Před 4 lety

    👍👍👍

  • @atmiksoni5859
    @atmiksoni5859 Před 4 lety

    where is code of this tutorial in git

  • @user-ev3cs4mm9q
    @user-ev3cs4mm9q Před rokem

    Not working

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

    10:27