Closed vipinvkmenon closed 7 years ago
@vipinvkmenon Can you give an example of the messages or exceptions given when the application fails to start? An example of the VCAP_SERVICES
environment variable created for the failing app would be helpful also.
This is likely caused by the fact that Spring Cloud Connectors (which Java buildpack's auto-reconfiguration uses) does not currently support Redis sentinels. See https://github.com/spring-cloud/spring-cloud-connectors/issues/185.
I’d agree that this is the root cause.
@vipinvkmenon For a "simple" connection to your HA redis service, the following configuration should do the job:
@EnableConfigurationProperties(RedisConnectionCloudProperties.class)
public static class RedisConnectionCloudConfiguration extends AbstractCloudConfig {
@Bean
public RedisConnectionFactory redisConnectionFactory(RedisConnectionCloudProperties properties) {
RedisConnectionFactory connectionFactory = connectionFactory().redisConnectionFactory(properties.getServiceId());
if(connectionFactory instanceof JedisConnectionFactory) {
JedisPoolConfig poolConfig = new JedisPoolConfig();
if(properties.getConnections() != null) {
poolConfig.setMaxTotal(properties.getConnections());
poolConfig.setMaxIdle(properties.getConnections());
}
poolConfig.setTestOnBorrow(true); // validate and drop closed connections
((JedisConnectionFactory)connectionFactory).setPoolConfig(poolConfig);
}
return connectionFactory;
}
}
@Validated @ConfigurationProperties(prefix = "yourapp.redis")
public static class RedisConnectionCloudProperties {
@NotNull private String serviceId;
private Integer connections;
public String getServiceId() { return serviceId; }
public void setServiceId(String serviceId) { this.serviceId = serviceId; }
public Integer getConnections() { return connections; }
public void setConnections(Integer connections) { this.connections = connections; }
}
Nevertheless, it would be very helpful if you could add an example of your VCAP_SERVICES environment variable to https://github.com/spring-cloud/spring-cloud-connectors/issues/185.
Since there’s been no response on this issue from the original in a couple of weeks, I’m going to close it. If you’d like to see it re-opened, please comment on the issue and I’ll reopen it.
When I deploy a Spring Application on CF. the java buildpack tries to reconfigure spring to work with its 'cloud' profile.
https://github.com/cloudfoundry/java-buildpack-auto-reconfiguration
As a result, the application picks up this configuration/profile.Due to this, the application fails when a Redis Multinode/HA instance is used.
I feel this is something to do with the way the HA/ Multinode Redis Service is deployed/ provided.
Our fix for the timebeing was to disable autoconfiguration through the manifest file.
JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '{enabled: false}'
Does Spring cloud not support Sentinels. Or is this due to some other issue?