Spring Cloud Config client- avoid property refresh on startup - spring-boot

I am using springcloud config server to refresh my application properties at the runtime on scheduled basis in production environment. My schedule runs biweekly without any issues.
My application is running on Kubernetes cloud on multiple pods. Pods tends to crash or restart at any moment. What happens in case of pod crash/restart it fetches the latest property file from Config Server and repository at application startup rather waiting for next scheduled refresh cycle.
This lead to inconsistencies across the pods configuration and application behavior.
What I am looking for a strategy to avoid property refresh at the app startup and "Spring cloud config" client to only refresh based on refresh cycle.
Any suggestions to solve above would be greatly appreciate.

You want to use old properties even your application gets restarted so you need to keep old properties detail somewhere. You can not do that in your application as property detail is coming from config server so its better to set refresh rate for config server also how frequent it should pull config detail from git or whatever is your source.
If you set refresh-rate to two week of config server it will contain old property detail only and does not matter how frequent your application restarted it will get old properties from config-server.

Related

How to configure Routing Datasource in Jhipster?

I have used Jhipster to develop quite a few applications however today I run into a little problem and it is how to configure Transaction Routing Datasource in Jhipster. I am using Kubegres to set up a Postgresql server with multiple read replicas and one write replica. I have configured a project to use Spring's Transaction Routing Datasource and I have succeeded in configuring it, but when I try to do the same configuration with Jhipter for another project and although I manage to get it to run without problems, it does not route for read-only replicas. Has anyone had the same problem and managed to get it to work

Spring boot Redis cache TTL property change on the fly

is it possible to change the TTL property of Redis cache during the runtime if the same property has been changed in app config server? is there a way to automate the process to refresh the Redis instance properties during runtime on the event of config server change?
If you want to get the latest property in Config Server, it is recommended to do it through the client polling method, which can be found at
https://learn.microsoft.com/en-us/azure/spring-apps/how-to-config-server#config-server-refresh
Regarding the load to Redis instances, you may need to write some code to send out the event.

Autoscaling up in Mongo with Spring Boot

I am setting up an application connecting to mongoDB with high availability.
I have studied the documentation and setup the replica set successfully through
spring.data.mongodb.uri=mongodb://user:secret#mongo1.example.com:12345,mongo2.example.com:23456/test
As the application property file is fixed, the application is required to restart if I change the spring.data.mongodb.uri.
What if I have a new replica member in mongo, should I need to restart my application with the update in application property?
Or, is it fair enough to use the old configuration? Mongo driver will automatically connect to the new replica member for me with the old configuration.
If you are loading properties from the file you need to restart the application once the property is updated.
Otherwise, you need to use some global property management apps like consul which when the properties are changed it will reload the properties value in the application(#RefreshScope).
In your case, once the property is changed you need to disconnect and reconnect to the mongodb by code.

Spring Config Service with Git

I'm going to use Spring Config Service (SCS) for our Microservices Architecture.
Currently our Cloud stack is on AWS.
Since SCS will run on a Docker, thanks to a Pipeline + Cloud Formation, and our config repository will be on a private GitHub repository with encrypted values:
Is there any best practice to refresh the repository that will be "pulled" inside the Docker?
How can I update it on any instances? (since my service will be load balanced with HA).
pleas refer following poc
https://github.com/pooja-varma/cloud-config-and-eureka-server
may be it helps you
Config clients don't poll for changes. It has to be triggered and there is a EnvironemntChanged listened by the application and any changes in the properties will be loaded again. If you need more control over when it has to be refreshed and if you want that to be atomic I would recommend you to use #RefreshScope which are lazy proxies and initialized only when they are used. The Environment of your application is pulled every time and it also actuator endpoints to the rescue as well.
Please refer the documentation here.
http://cloud.spring.io/spring-cloud-static/docs/1.0.x/spring-cloud.html#_refresh_scope

Session survival with continuous delivery

I'm working with an application in jsf and continuously Delivery to Heroku. I'm new to both JSF and Heroku.
I don't know if it's possible but my wish is to be able to do minor updates on the application, deploy to Heroku but still let the sessions survive for the session scoped manage beans. I have set the State saving to be client in my web.xml but when I deploy the application to Heroku all the values in the manage beans are reset to their init values.
Does anyone know how to fix this? Thank you
On Heroku you need to externalize your session state (or preferably don't use session state, which unfortunately isn't an option with JSF). Configuring your app server to do this is usually pretty easy but it depends on which app server you are using. Here is how to do it with Jetty and MongoDB as the session store:
http://www.jamesward.com/2011/11/30/using-mongodb-for-a-java-web-apps-httpsession

Resources