Я создал многомодульный проект Spring boot с салатом. Моя конфигурация:
@Bean
public LettuceConnectionFactory lettuceConnectionFactory(){
return new LettuceConnectionFactory(host, port);
}
@Bean
public RedisTemplate<String, FullMessage> redisTemplate() {
RedisTemplate<String, FullMessage> template = new RedisTemplate<>();
template.setConnectionFactory(lettuceConnectionFactory());
return template;
}
Я использую RedisTemplate другой модуль асинхронно:
@Async
@EventListener(ApplicationReadyEvent.class)
public void check() {
while (true){
try{
List<ObjectRecord<String, FullMessage>> records = redisTemplate
.opsForStream()
.read(FullMessage.class, StreamOffset.fromStart(key));
...
}
Этот код не работает в многомодульном проекте, но работает с другим проектом (не с несколькими модулями), я получаю следующая ошибка (бесконечность):
java.lang.IllegalStateException: Cannot connect, Event executor group is terminated.
at io.lettuce.core.AbstractRedisClient.initializeChannelAsync(AbstractRedisClient.java:283)
at io.lettuce.core.RedisClient.connectStatefulAsync(RedisClient.java:314)
at io.lettuce.core.RedisClient.connectStandaloneAsync(RedisClient.java:271)
at io.lettuce.core.RedisClient.connect(RedisClient.java:204)
at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.lambda$getConnection$1(StandaloneConnectionProvider.java:115)
at java.base/java.util.Optional.orElseGet(Optional.java:369)
at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.getConnection(StandaloneConnectionProvider.java:115)
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:1197)
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getConnection(LettuceConnectionFactory.java:1178)
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getSharedConnection(LettuceConnectionFactory.java:942)
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getConnection(LettuceConnectionFactory.java:353)
at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:132)
at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:95)
at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:82)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:215)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:188)
at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:96)
at org.springframework.data.redis.core.DefaultStreamOperations.read(DefaultStreamOperations.java:217)
at org.springframework.data.redis.core.StreamOperations.read(StreamOperations.java:319)
at org.springframework.data.redis.core.StreamOperations.read(StreamOperations.java:290)
at uz.test.websocket.config.MainFIFOListener.check(MainFIFOListener.java:49)
at uz.test.websocket.config.MainFIFOListener$$FastClassBySpringCGLIB$$a659b30d.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)