Read property values from redis server, if redis connection is not available then read it from application.properties file - spring-boot

Spring, read all the property values on startup, but, I have to read all the property values from redis server instead of application.properties file.
If redis server connection is not available due to any reason, then the property values should be read from application.properties file.

Related

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.

Jetty Spring Boot with session replication

I am using spring boot 2.5.3 with Jetty 9.4.43.v20210629. I want to share the session across multiple nodes. In Jetty 9.4 there are lot of changes in session management. I want some reference materials for session replication (using JDBC / File system) with java configurations.
Session replication can be done using spring session with following storage options,
Hazlecast
Database
Redis
MongoDB
spring.session.store-type property should be used to decide the storage type. When multiple nodes / containers point to same storage it will share the session and no need to maintain a sticky session.
Need to add proper dependencies in pom.xml and add annotations when required (ex: #EnableJDBCHttpSession)
sample application yaml changes.
JDBC
spring:
application.name: console-bs
main.allow-bean-definition-overriding: true
profile: default
session.store-type: jdbc
session.jdbc.initialize-schema: always
jpa.database: mysql
jpa.database-platform: org.hibernate.dialect.MySQL5Dialect
datasource.url: jdbc:mysql://mysqldb:3306/user
datasource.username: user
datasource.password: user1234#
datasource.driver-class-name: com.mysql.cj.jdbc.Driver
Redis
spring:
application.name: console-bs
main.allow-bean-definition-overriding: true
profile: default
session.store-type: redis
redis.host: redis
redis.port: 6379

Want to read gateway properties from config server

I have a spring cloud gateway in my project and I want to use config server with that.
What exactly I want to do is
enter image description here
I want to read these highlighted values from config server.
i kept these values in config server, still it reads the values from application property not from config,,,, Can som1 plz help here
when i use #value to read these values then it takes config server values...
Is it like config server only works with #value????

Difference between bindings file and jndi properties file

Can you please let me know when to use .bindings file and when to use jndi properties file?
The .bindings file is created by the JNDI FileSystem context (com.sun.jndi.fscontext.RefFSContextFactory) when data is stored by the MQ JMSAdmin tool or other JNDI tool. It contains a representation of the JNDI data, for example your Connection Factory settings such as hostname, port, etc.
In the case of MQ, the .bindings file is not used directly by MQ code, it is used by the JNDI code to create the MQ JMS objects which are then returned to the application.
The JNDI properties file (or the JMSAdmin.config file if you're using JMSAdmin) stores the connection settings to allow the JNDI code to connect to the JNDI repository (for example, the FileSystem context, LDAP server etc.). It does not contain data such as Connection Factory settings.

Strange behavior with log4j2 configuration

I am working with spring cloud and log4j2 with "all" as level.
I will describe two situations with the same config file, I want to write on a Syslog TCP.
First test: I puth my log4j2 config file in resources folder, then, I start my app and start logging to the syslog.
But I need my configuration on a git, so I expose it to an url.
So here comes the second test:
I changed my bootstrap.yml and and the followind line:
logging: config:
http://xxx.xx.xx.75:3000/admin123/config-repository/raw/master/log4j2.xml
Then, I started my app and it starts to write the logging lines of spring boot in my syslog, but, when I put:
LOGGER.info("printing lalala");
Nothing is writed in the syslog and I can see a [FIN, ACK] beetween client and server on my TCP connections.
So, I understand that the config file is readed from the repository, becouse I can see it in my connections capture and becouse the app starts to log on syslog some lines, but something happend after that to close connection and write no more.
I can`t understand what is happening.
You must add the path of the logging.config on the application.yml not the bootstrap.yml and it works.

Resources