Fix: Fanout exchange messages mixed across virtual databases in Redis sentinel

This commit is contained in:
huyenvu2101 2024-04-22 12:40:20 +07:00 committed by Asif Saif Uddin
parent a56abf6890
commit 4d281948f2
2 changed files with 14 additions and 0 deletions

View File

@ -1433,6 +1433,8 @@ class SentinelChannel(Channel):
).connection_pool
def _get_pool(self, asynchronous=False):
params = self._connparams(asynchronous=asynchronous)
self.keyprefix_fanout = self.keyprefix_fanout.format(db=params['db'])
return self._sentinel_managed_pool(asynchronous)

View File

@ -1634,6 +1634,18 @@ class test_RedisSentinel:
connection.channel()
p.assert_called()
def test_keyprefix_fanout(self):
from kombu.transport.redis import SentinelChannel
with patch.object(SentinelChannel, '_sentinel_managed_pool'):
connection = Connection(
'sentinel://localhost:65532/1',
transport_options={
'master_name': 'not_important',
},
)
channel = connection.channel()
assert channel.keyprefix_fanout == '/1.'
def test_getting_master_from_sentinel(self):
with patch('redis.sentinel.Sentinel') as patched:
connection = Connection(