ReactiveRedisMessageListenerContainer doesn't manage the number of subscribers for each subscription but always creates a new one

95 views Asked by At

I'm using ReactiveRedisMessageListenerContainer but need help with some questions, in particular how subscriptions are handled with Lettuce.

In the class there is a map: Map<ReactiveSubscription, Subscribers> subscriptions When the doReceive method is called, it uses LettuceReactivePubSubCommands and creates a new subscription using getRequiredConnection().pubSubCommands().createSubscription(subscriptionListener)

When executing the internal doreceive method, the created subscription with a number of subscribers equal to 1 is added to the map.

So for example, if you have 2 requests with the same patterns&channels, two key instances are always created in the map with subscribers=1. Instead, I would have expected a management that, with the same channels and patterns, used the same subscription instance in the map by increasing subscribers to 2 and managing with register unregister.

Is there a reason behind this choice or is there something I didn't understand? I couldn't find documentation on this. Thanks in advance

I customized this management by modifying ReactiveRedisMessageListenerContainer, but whoever implemented this behavior seems to have done so with a very specific choice, I would like to understand why or if there is a different way.

0

There are 0 answers