A system I'm working on currently is receiving messages in redis. I would like to write a python script that can read in those messages , modify them and return them to a different channel/key in redis.
For example:
redis-cli -a 'redis' monitor | grep '"pushName"'
will return :
1707963448.404618 [0 192.168.86.75:51520] "LPUSH" "pushName" "{\"uuid\":"be70\"...,{}}
How do I subscribe to get the messages from pushName because when I try to do this
mobile = r.pubsub()
mobile.subscribe('pushName')
for message in mobile.listen():
print(message)
Nothing displays execept for :
{'type': 'subscribe', 'pattern': None, 'channel': 'pushName', 'data': 1}
. I already know my connection criteria is fine because I can get a list of the channels when I do this:
index_list = []
for key in r.scan_iter('*'):
index_list.append(key)
But messages are flying when I do :
redis-cli -a 'redis' monitor | grep '"pushName"'
You seem to be confusing debug output with messages, with Redis LISTs and with Redis Pub/Sub.
If your other (real) code is doing LPUSH operations it is appending items to a Redis LIST.
Those LPUSH operations will show up in your
redis-cli monitorcommand because that is a debugging tool showing you all Redis internal operations.The LPUSH commands (which operate on a Redis LIST) will not show up when you subscribe to Redis Pub/Sub because that is a completely separate feature of Redis and you will only see messages when you subscribe to a topic and when somebody publishes on that topic... but nobody is doing any publishing as such, they are only doing LPUSH to a LIST.