spring-config-client received multiple refresh event when ever there is a change in consumer-group-name - spring-boot

i am using spring cloud config server, kafka, git and spring cloud bus for to auto-refresh my client properties but when ever i am restarting my client application first time by changing consumer-group-name then i observed that during startup my client application Received remote refresh request multiple times which is equal to the no of times i have committed my client properties changes , but i want to avoid such multiple refresh request during startup.
'spring.cloud.stream.default.group' is the property which i used to define the
consumer-group-name at client application.

Related

How to know get notified in apache geode spring boot client application in disconnection and reconnection status from geode server

I am developing a Spring Boot Client cache application (spring-geode-starter version 1.7.5), which connects a gfsh locator and server ( say locator1 , server1).
During startup of the client application, spring boot automatically connects the locator and server running.
Now if I stop server from gfsh terminal , I observe in log, the client application gets notified with some log console messages.. also when i restart server from gfsh, i see client log message of auto reconnection done towards server.
My objective is : how to handle in some event listener in my client application code to get notified these disconnect and reconnect events, so that I need to do some extra logic work during these events.
can any one suggest and help me..

Spring Cloud Config client- avoid property refresh on startup

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.

How to read events for newly modified record from keycloak to spring boot

Actually We have following flow and scenario to poll data in to my Spring boot App
Active Directory --> Keycloak --> Spring boot App
Here we are able to poll data in but in future if there is any record change in Active Directory keycloak has a provision to poll data in it's DB periodically but the same changed (Newly Added /Deleted /Updated ) records from key cloak to Spring boot application there is some eventing option but I do not see how and where to implement it ?
I suppose there should be a listener in the spring boot application which would get triggered on any change in record (Newly Added /Deleted /Updated ) of keycloak
The event listener is implemented on the Keycloak side. Here is an example of how to implement an event listener that logs events to console - Event Listener Example
Instead of logging, you will need to send notifications to your SpringBoot application in any suitable way:
you can implement some endpoint in your SpringBoot application that will be invoked by Even Listener's code
or Event listener can send let's say JMS message and your SpringBoot application will be subscribed to the JMS topic
etc.

How to refresh config clients automatically?

I am new to Spring Config Server/Client technologies.
I am using a spring config server to hold some config values.
Config clients will connect to the server and get the values.
If i change some of the config values at the config server, then currently I have to refresh the clients to load the config details from config server again by invoking "/refresh" on each client.
Is there anyway the clients will be notified by the config server and they will then reload the configuration again ?
Yes there is a way.
The solution is to use the Spring Cloud Bus. Using this module, you would link multiple clients to the server using a message broker. The only message broker implementation currently supported by this module is AMQP. Once the clients are connected to the server, invoking the endpoint on the server /bus/refresh will automatically broadcast the configuration changes to all the subscribed clients. This therefore means it is possible to reload configuration changes for any number of clients with one single refresh request which originates at the server.

Spring without views

I am new to spring and so not sure if what I intend to do is possible.
I need to create an asynchronous webservice and a worker server (broker), both using the model & controller aspects of spring.
The webservice needs to send it's client's requests on to the broker via JMS and then instantly send a response back to the client indicating the request has been queued.
The broker is intended to remain live, processing messages from multiple webservice instances and sending back the results via an output JMS queue. The reason the broker needs to remain live is because the work to process each webservice message involves calling other webservices, some of which may be asynchronous and which may take a lot of time to process.
Additionally I do not want to spawn multiple instances of the broker as it is designed to handle multiple concurrent messages.
Is it possible to create both the webservice and broker within the same spring project, with both running in a web container such as tomcat or do I need to code them in separate projects, with perhaps the broker as a traditional standalone server rather than a web container servlet?
If so could someone point me in the right direction to creating a stay-alive broker within spring/tomcat.
I understand the webservice and JMS side of things, so do not need any help with that.

Resources