You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@petyaslavova : Thank you but I got it to work,
Subscriber is below
from redis.cluster import RedisCluster, ClusterNode
import time
r = RedisCluster(startup_nodes=[ClusterNode('rediscache-0001-001.awsclusterurl.com', 6379), ClusterNode('rediscache-0002-001.awsclusterurl.com', 6379)], ssl=True)
jamna=r.get_node_from_key("jamnachikochiki")
p = r.pubsub(node=jamna)
p.ssubscribe("jamnachikochiki")
while True:
message = p.get_sharded_message(ignore_subscribe_messages=False, timeout=1, target_node=jamna)
print(message)
time.sleep(1)
~
Publisher
from redis.cluster import RedisCluster, ClusterNode
# Connect to Redis Cluster
r = RedisCluster(
startup_nodes=[
ClusterNode('rediscache-0001-001.awsclusterurl.com', 6379),
ClusterNode('rediscache-0002-001.awsclusterurl.com'', 6379)
],
ssl=True
)
node = r.get_node_from_key("jamnachikochiki")
args = ("jamnachikochiki", "Test message for sharded pub/sub")
print(node)
response = r.execute_command("SPUBLISH", *args, target_nodes=node)
print(response)
Two changes I made
p.get_sharded_message(ignore_subscribe_messages=True, timeout=1, target_node=jamna) changed this to
p.get_sharded_message(ignore_subscribe_messages=False, timeout=1, target_node=jamna)
and I deleted the slave nodes for redis,
Not sure if it was related to slave nodes or the ignore_subscribe_messages=False,
Thanks I am unblocked for now spent hours but figured it out!! :)
I am doing like that but is there a way the library can do it for me ?
Also I am using AWS elastic cache
The text was updated successfully, but these errors were encountered: