Using Spring cloud config in multi application architecture - spring

I am currently using Spring external configuration by creating a config server, config client and a Git repository with property files. Is there any way to use this config server for multiple applications?
My Current Architecture:
Created a Git repository with config files.
Created a Config Server which connects to the above Git repository for property files.
Created a Client (Spring boot application) which connects to the config server to load the properties.
When there is a change in any of the property files, I am invoking the refresh method of config client to refresh the properties. If there are multiple applications using the same config server and git repository for property files, what should be the approach to refresh all the properties without invoking the /refresh method of all the applications?
I tried /refresh of the config server but it doesn't refresh the properties as they are loaded during the application startup.

Related

Is there bootstrap file in Quarkus application ? I can read external config files using spring cloud config server client

I can read external config files using spring cloud config server client at runtime, but before the application startup I can't not. I can't use external config files for like database connection or kafka topic. Does anyone know something?
Spring has a file like bootstrap is used before starting application and retrieve all of configurations. But Quarkus client does not do that, It retrieve the properties after application status ready
You can use quarkus.config.locations to load external files from any location: classpath, folder, HTTP, etc (just needs to be a valid URI).
Please check: https://quarkus.io/guides/config-reference#quarkus-config-config_quarkus.config.locations

when spring cloud config server calls the github repository?

I mean spring cloud config server fetches all client api's configuration during startup ?
or
spring cloud config server fetch the client API configuration, when that client api calls the config server?
That behaviour is controllable via a property:
spring.cloud.config.server.git.clone-on-start
Flag to indicate that the repository should be cloned on startup (not on demand). Generally leads to slower startup but faster first query.
Default:
false
So the default behaviour is that the repo will only be cloned when a client first makes a request to the server, but if you set the property to true, then the server will clone the repository when it starts and the configuration will be available to the client's first request faster

Update keycloak from config file

I am using keycloak embedded into spring application explained in this tutorial https://www.baeldung.com/keycloak-embedded-in-spring-boot-app
There is a configuration file for keycloak that is contained within that application, but the configuration is imported into keycloak and into database only the first time that application is started.
Is there a way to make updates on that config file reflect on the state of the keycloak?
Developers should be able to change configurations and push changes to version control. When somebody pulls the new configuration it should reflect on his local instance of keycloak.

spring cloud config client set config url at property file

I have a spring cloud project. There are config server (config-srv), eureka server (eureka-srv) and some other service with business logic, let's call it main service (main-srv).
I'm packaging them into jars and run one by one. My apps get their properties from a file in the same directory with jars.
So, I'm setting properties to config-srv through "application-native.properties".
But if i want to change config-srv url (for example, i want http://localhost:9999), how can i share this url for all micro-services before they will boot ? I'm trying to share this url in "application-default.properties" but it makes no effect.
You can put the Spring Cloud Config server details in bootstrap.properties file in each microservices.
spring.application.name=microserviceName
spring.profiles.active=dev
spring.cloud.config.uri=http://localhost:9999
spring.cloud.config.username=your_username
spring.cloud.config.password=your_password
Go through the link to have more detail about spring cloud config
https://howtodoinjava.com/spring-cloud/spring-cloud-config-server-git/

spring-cloud-config client not getting refreshed on property change

How can I get my spring-boot application (client) to refresh it's properties - which are coming from spring-cloud-config stand alone Server? I've annotated #RefreshScope, added config in bootstrap.yml for spring.cloud.config.uri and spring.application.name I can see server is able to get the config using it's HTTP end-pt and also Client gets the config using spring-boot /manage/env end-pt. It's just that if I commit a property change to git, it is not changing in my Client App.

Resources