spring-guides/gs-messaging-redis

Add guide on configuring port and hostname

harryge00 opened this issue · 6 comments

I am not familiar with spring framework. I tried to use setHostname/setPort or RedisStandaloneConfiguration to configure host/port, but it always reported error ...
I think as guide for spring, it will be beneficial adding example on configuring host/port instead of using the default config. Thanks

I think we shouldn't change the heading, but I also think it's a reasonable request to add how to set the host and port. Thanks for the feedback, @harryge00

Gary: If you're not the right person to describe that, please let me know. Also, if you want help with the wording, please let me know. I'll review it anyway, though. Thanks much.

dsyer commented

+1 for a doc link. And the same for rabbit and Kafka guides.

I finally figured out a way to configure 😂:

       # Add another function:
       @Bean
	public RedisConnectionFactory redisConnectionFactory() {
		RedisStandaloneConfiguration redisConfig = new RedisStandaloneConfiguration("1.2.3.4", 6379);
		redisConfig.setPassword(RedisPassword.of("somepassword"));
		return new LettuceConnectionFactory(redisConfig);
	}

Using application.properties would be more elegant though. Thanks for your reply.

RedisConnectionFactory is configured by Spring Boot, so +1 to add a link to the Boot docs that explain Redis properties related to the endpoint configuration.

I added #26 to replace this one.