spring-data-redis icon indicating copy to clipboard operation
spring-data-redis copied to clipboard

RedisMessageListenerContainer does not work with Forwarding LettuceConnectionFactory

Open leeychee opened this issue 3 years ago • 0 comments

If we use a forwarding RedisConnectionFactory, which does not extends the LettuceConnectionFactory, and delegate the get connection to LettuceConnectionFactory, then the RedisMessageListenerContainer does not work anymore. It works in 2.6.13.

public class RedisConnectionProxyFactory
        implements RedisConnectionFactory, ReactiveRedisConnectionFactory {

    private final LettuceConnectionFactory innerFactory;

    public RedisConnectionProxyFactory(LettuceConnectionFactory factory) {
        this.innerFactory = factory;
    }

    @Override
    public RedisConnection getConnection() {
         return innerFactory.getConnection();
    }
}

It seems caused by this method, the isAsync() is false, so the subscribe is close immediately, and the Container stops working.

private Subscriber createSubscriber(RedisConnectionFactory connectionFactory, Executor executor) {
	return ConnectionUtils.isAsync(connectionFactory) ? new Subscriber(connectionFactory)
			: new BlockingSubscriber(connectionFactory, executor);
}

leeychee avatar Nov 04 '22 14:11 leeychee