Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnThreading;
import org.springframework.boot.thread.Threading;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.data.redis.annotation.EnableRedisListeners;
import org.springframework.data.redis.config.RedisListenerConfigUtils;
import org.springframework.data.redis.connection.RedisConnectionFactory;
Expand All @@ -46,10 +49,23 @@ class DataRedisAnnotationDrivenConfiguration {

@Bean
@ConditionalOnMissingBean
@ConditionalOnThreading(Threading.PLATFORM)
RedisMessageListenerContainerConfigurer redisMessageListenerContainerConfigurer() {
return new RedisMessageListenerContainerConfigurer(this.properties);
}

@Bean(name = "redisMessageListenerContainerConfigurer")
@ConditionalOnMissingBean
@ConditionalOnThreading(Threading.VIRTUAL)
RedisMessageListenerContainerConfigurer redisMessageListenerContainerConfigurerVirtualThreads() {
RedisMessageListenerContainerConfigurer configurer = new RedisMessageListenerContainerConfigurer(
this.properties);
SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor("redis-");
executor.setVirtualThreads(true);
configurer.setTaskExecutor(executor);
return configurer;
}

@Bean(name = DEFAULT_MESSAGE_LISTENER_BEAN_NAME)
@ConditionalOnSingleCandidate(RedisConnectionFactory.class)
@ConditionalOnMissingBean(name = DEFAULT_MESSAGE_LISTENER_BEAN_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import org.springframework.boot.data.redis.autoconfigure.DataRedisProperties.Listener;
import org.springframework.boot.data.redis.autoconfigure.DataRedisProperties.Recovery;
import org.springframework.core.retry.RetryPolicy;
import org.springframework.core.task.TaskExecutor;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.lang.Nullable;
import org.springframework.util.backoff.BackOff;

/**
Expand All @@ -42,10 +44,21 @@

private final DataRedisProperties properties;

@Nullable

Check warning on line 47 in module/spring-boot-data-redis/src/main/java/org/springframework/boot/data/redis/autoconfigure/RedisMessageListenerContainerConfigurer.java

View workflow job for this annotation

GitHub Actions / Build Pull Request

[deprecation] Nullable in org.springframework.lang has been deprecated

Check warning on line 47 in module/spring-boot-data-redis/src/main/java/org/springframework/boot/data/redis/autoconfigure/RedisMessageListenerContainerConfigurer.java

View workflow job for this annotation

GitHub Actions / Build Pull Request

[deprecation] Nullable in org.springframework.lang has been deprecated

Check warning on line 47 in module/spring-boot-data-redis/src/main/java/org/springframework/boot/data/redis/autoconfigure/RedisMessageListenerContainerConfigurer.java

View workflow job for this annotation

GitHub Actions / Build Pull Request

[deprecation] Nullable in org.springframework.lang has been deprecated
private TaskExecutor taskExecutor;

public RedisMessageListenerContainerConfigurer(DataRedisProperties properties) {
this.properties = properties;
}

/**
* Set the {@link TaskExecutor} used to run listener callbacks.
* @param taskExecutor the task executor
*/
public void setTaskExecutor(@Nullable TaskExecutor taskExecutor) {

Check warning on line 58 in module/spring-boot-data-redis/src/main/java/org/springframework/boot/data/redis/autoconfigure/RedisMessageListenerContainerConfigurer.java

View workflow job for this annotation

GitHub Actions / Build Pull Request

[deprecation] Nullable in org.springframework.lang has been deprecated

Check warning on line 58 in module/spring-boot-data-redis/src/main/java/org/springframework/boot/data/redis/autoconfigure/RedisMessageListenerContainerConfigurer.java

View workflow job for this annotation

GitHub Actions / Build Pull Request

[deprecation] Nullable in org.springframework.lang has been deprecated

Check warning on line 58 in module/spring-boot-data-redis/src/main/java/org/springframework/boot/data/redis/autoconfigure/RedisMessageListenerContainerConfigurer.java

View workflow job for this annotation

GitHub Actions / Build Pull Request

[deprecation] Nullable in org.springframework.lang has been deprecated
this.taskExecutor = taskExecutor;
}

/**
* Configure the specified Redis message listener container. The container can be
* further tuned and default settings can be overridden.
Expand All @@ -54,6 +67,9 @@
*/
public void configure(RedisMessageListenerContainer container, RedisConnectionFactory connectionFactory) {
container.setConnectionFactory(connectionFactory);
if (this.taskExecutor != null) {
container.setTaskExecutor(this.taskExecutor);
}
PropertyMapper map = PropertyMapper.get();
Listener listenerProperties = this.properties.getListener();
map.from(listenerProperties::isAutoStartup).to(container::setAutoStartup);
Expand Down
Loading