psubscribe patterns not working correctly?
See original GitHub issueI’m trying to publish status messages for each process that gets forked within a script. Each channel is named as status_
followed by some unique identifier, job_id
. So I was hoping to use psubscribe
to subscribe to all channels matching the pattern status_*
, but I’m having trouble doing so. It seems to work OK if I replace the call to redis.psubscribe
with a regular redis.subscribe
and hard-code the correct channel name, but that defeats the purpose.
redis.psubscribe('status_*', function(error, count){})
redis.on('message', function (channel, message) {
console.log('Received message \'%s\' from channel \'%s\'', message, channel);
});
Then, on another script, I publish a message to the channel
var channel = 'status_' + job_id;
redis.subscribe(channel, function(error, count){
pub.publish(channel, someMessage);
});
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Redis PSUBSCRIBE Problems - Stack Overflow
A server is sending a message via Redis on a channel composed of some name and a unique id. I need to essentially...
Read more >Redis PSUBSCRIBE - How to subscribe to multiple patterns in ...
Learn how to subscribe to one or more patterns in redis message broker system using redis-cli. Redis PSUBSCRIBE command, Redis Tutorial.
Read more >Pub/Sub (Publish and Subscribe) - Eventide
Pub/Sub pattern is a messaging pattern that enables a loose coupling of ... attention to getting the message schemas right so that they...
Read more >Publish-Subscribe Pattern: The Most Used Patterns in ...
Once the weather station issues a weather warning, they will do the following things: Building site: stop work; Ships: mooring; Tourists: cancel the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@saschaishikawa Oh yes, one more thing… when you psubscribe, you need to watch for pmessage instead of message.
redis.on(‘pmessage’, function(channel, pattern, message) {});
😃
if everyone comes after the order has changed:
sub.on('pmessage', (pattern, channel, message) => {})