I have an application which inserts record to a postgresql table and after the insert, I want to send a PUBLISH command to redis. Is it possible to pass an object of that record to redis' PUBLISH command so the subscriber on the other end will receive the object too?
In a Redis Cluster clients can publish to every node. The cluster makes sure that published messages are forwarded as needed, so clients can subscribe to any channel by connecting to any one of the nodes.
Redis Pub/Sub implements the messaging system where the senders (in redis terminology called publishers) sends the messages while the receivers (subscribers) receive them. The link by which the messages are transferred is called channel. In Redis, a client can subscribe any number of channels.
1 Answer. Show activity on this post. First of all, if you are using PUBLISH, then it is blocking and returns only after messages have been delivered, so yes the order is guaranteed.
To start with, the publish isnt blocking the process. In the pub/sub system, the publisher pushes the message, and the subscriber is an always blocking synchronous process.
Redis has no meaning of "objects", all redis gets are bytes, specifically strings!
So when you want to publish an object you have to serialize it some way and deserialize it on the subscriber.
Yes, but because redis stores strings rather than objects, you'll need to serialize/unserialize objects as part of the PUBLISH process. JSON is an ideal format for this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With