Connecting to Redis Cluster from Spring Boot caching abstraction - spring-boot

I am using Spring Boot with Caching abstraction support to connect to redis-server for storing/fetching data for caching.
I use the below properties for connecting to redis-server.
spring.redis.host=localhost
spring.redis.port=6379
spring.redis.password=mypassword
spring.cache.type=redis
I am able to successfully connect to redis server and store/fetch data.
For high availability,it is decided to use 3 nodes , 1 master and 2 slave nodes for redis server.
In that case, I am not sure how to provide the configuration to connect to redis cluster from my spring boot application.
Are there any properties supported by spring boot to connect to redis cluster.
I am using out-of-box support of spring caching abstraction with support for annotation #cacheable.
I have the below 2 dependencies added to my pom.xml
spring-boot-starter-cache and spring-boot-starter-data-redis
and also using spring boot 1.5.13.
Is there support for connecting to redis cluster when using spring caching abstraction in spring boot.

Related

Spring Cassandra repository with manual connection

I want to use spring data Cassandra but I don't want use spring boot configured connection. I will create a connection which has to be used by Cassandra repository. Is this possible

Hazelcast +Sring Boot + Kubernetes - How to setup Client-Server topology

I'm trying to see how to configure Client-Server with my Spring Boot application using Hazelcast on Kubernete, since we want to have the capability of sharing the cache between different Spring Boot applications (I'm already able to setup the Embedded distributed cache with Kubernetes - which is not what we need).
In case of Spring Boot single application(not on Kubernetes), its kind of easy where i will spin up a Server lets say with 'localhost' and also spin up the client connecting to localhost. Also i can have multiple instances(members) of Server which will form a Hazelcast Cluster.
However in case of Kubernetes, I know we need to have 2 different Spring Boot applications, one will act as a Server and others will be client accessing the cache, but want to know how the client would connect to the Server. Because in case of Spring we Autowire the HazelcastInstance, so how would i connect to the Server which is running in its own Kubernetes Pod ( and container).
There are a few deployment guides for Kubernetes here, and worked examples here & here.
If your server pods are joining, then you pretty much have it. A client uses the same discovery mechanism.
Add the hazelcast-kubernetes plugin to the client's pod, and set the configuration properties with the same values as you use on the server for namespace, dns, etc.
Thanks Neil. As you indicated its the same way i currently configured in embedded caching on Kubernetes. I'am using the Service-Name and namespace to discover and connect to the Server members from HazelcastClient instance.
This is from Client Spring Boot application's HazelcastConfiguration:
#Bean
public HazelcastInstance hazelcastInstance() {
final ClientConfig config = new ClientConfig();
config.setClusterName("cluster-name");
if (enableOnK8s) {
config.getNetworkConfig().getKubernetesConfig().setEnabled(true)
.setProperty("namespace", namespaceValue)
.setProperty("service-name", serviceName);
}
return HazelcastClient.newHazelcastClient(config);
}
And on Hazelcast Server Spring Boot application, configuration stays same as Embedded Hazelcast configuration.

How do I setup connection pooling in spring boot for Elasticsearch

I have created a spring boot application that uses spring boot starter data elasticsearch to connect to elasticsearch. I want to configure this application to setup connection pooling. How do I configure the application.properties to support it?
Old answer. Since Boot 2.2, the reactive client doesn't have these options.
From the docs:
spring.data.elasticsearch.properties.*= # Additional properties used to configure the client.
Though it does appear that the default TransportClient does pool connections anyway.

how to connect with gemfire running on local machine using spring data gemfire with annoatations

I have tried so many demos but I am not able to create region on my local gemfire .
my code is running in embedded mode but I want to run it as client server mode with using annotions how should I do this.
Thanks.
Your problem description is pretty vague.
You should have a look at my pivotal-gemfire-clientserver-examples that compares and contrasts using native GemFire configuration (both cache.xml and then using GemFire's Java API) vs. Spring configuration (again using both Spring XML as well as Spring Java configuration meta-data).
For instance, you can see here that I configured and bootstrapped a GemFire Server using Spring Boot along with a Java configuration class. The GemFire cache client is my test class (along with the client-side Java config), but easily could have been another standalone, Spring Boot application.
Another, interesting tidbit, is that you can connect to the Spring Boot, GemFire Server application using Gfsh once the server is up and running. To connect in gfsh, use...
gfsh>connect --jmx-manager=localhost[1199]
Hope this helps!
-John

Discovering Hazelcast instance in a Spring Boot eco-system

Background:
We have a set of about 15 Spring Boot applications as microservices. They all run as Docker containers, and run as clusters of one or more instances. We also use Spring Cloud Netflix components such as Eureka and discover the running application instances from the client using Feign/Ribbon.
Question:
As part of the POC exercises, we tested with Redis and Hazelcast for caching and Spring Boot configuration storage. Everything works using Spring Boot, Spring Cloud and Redis/Hazelcast Java client libraries. However, when we deploy Hazelcast in a multi-node peer-to-peer cluster, Hazelcast seems to require a "known" IP address/hostname and the accessible port to be available in the Java client's configuration (with or without Spring). Typically, when Hazelcast is deployed in a multi-instance cluster on ephemeral VM instances (for example, EC2), the IP address and the port information is not available. So we thought of two possible solutions:
Find a way to run Hazelcast as a Spring Boot application, and register it with Eureka as a Discovery Client. That way other Spring Boot applications can use Eureka to discover an instance of Hazelcast dynamically
Find a way in Hazelcast so that it can publish it's IP address and port information dynamically to a central Key/Value store
If anyone has played around with Hazelcast to be able to do either/both of the possible solutions, it would be great if you can share more information on that. If there is a third approach that'd work better, I will be eager to know that as well.

Resources