publish-subscribe

Redis / Node.js - 2 clients (1 pub/sub) causing issues with writes

落爺英雄遲暮 提交于 2019-12-03 16:14:18
Trying to create two clients; one is pub/sub, the other is a standard connection. Is this not possible? There must be a way to abstract this to work :) Basically, if I do a get key after running test.js, all I see is 'valueBefore'. The output: node test.js Reply: OK /Users/franklovecchio/Desktop/development/node/node_modules/redis/index.js:487 throw new Error("Connection in pub/sub mode, only pub/sub commands may ^ Error: Connection in pub/sub mode, only pub/sub commands may be used at RedisClient.send_command (/Users/franklovecchio/Desktop/development/node/node_modules/redis/index.js:487:15)

Why can't I have a single Redis client acting as PUB and Sub in the same connection?

有些话、适合烂在心里 提交于 2019-12-03 14:32:07
My mental model was that of a 'chat', where I am subscribed to a certain channel and I can publish messages to this channel. Since pub/sub is asynchronous, the published message could appear at any time, including when you are expecting the response to a command. Although redis is single threaded, which normally prevents that sort of thing, network latency can cause some interesting effects - depending on the content of the messages, you could receive a valid response to a command before the server has actually received it. That said, you could probably use a single connection if you really

Scaling WebSockets with a Message Queue

心不动则不痛 提交于 2019-12-03 13:36:33
问题 I have built a WebSockets server that acts as a chat message router (i.e. receiving messages from clients and pushing them to other clients according to a client ID ). It is a requirement that the service be able to scale to handle many millions of concurrent open socket connections, and I wish to be able to horizontally scale the server. The architecture I have had in mind is to put the websocket server nodes behind a load balancer, which will create a problem because clients connected to

Nodejs: How to handle event listening between objects?

耗尽温柔 提交于 2019-12-03 13:23:46
问题 I currently have the problem that I have an object which should listen on another object. The question is: how should I handle the subscription? Currently, I only know of two possible ways: With registrator: var Registrator = function() { this.listener = new Listener(); }; Registrator.prototype.register = function(subsriber) { var self = this; subscriber.on('event', function(info) { self.listener.doSomething(info); }); }; In constructor: var Subscriber = function() { var listener = require('.

Why does Redis have Pub/Sub capabilities?

社会主义新天地 提交于 2019-12-03 10:31:37
Why does Redis , a datastore, have Pub/Sub features? My first thought is that it's the wrong layer to implement such a thing. But maybe I need to think outside the box. Redis is defined as data structure server. Redis provides multiple functionality like memcache, queue, pubsub etc. This is very useful for a cloudapp/webstack where 3 components RabbitMQ(queuing) + XMPP(pubsub) + Memcache can be currently replaced with redis. Queuing is not as feature rich as RabbitMQ though. That would be true if it was about feeds for end users to subscribe to. Actually it's closer to the concept of events or

Redis Cluster vs ZeroMQ in Pub/Sub, for horizontally scaled distributed systems

只愿长相守 提交于 2019-12-03 10:07:50
If I were to design a huge distributed system whose throughput should scale linearly with the number of subscribers and number of channels in the system, which would be better ? 1) Redis Cluster (only for Redis 3.0 alpha, if its in cluster mode, you can publish in one node and subscribe in another completely different node, and the messages will propagate and reach you). The complexity of Publish is O(N+M) , where N is the number of subscribed clients and M is the number of subscribed patterns in the system, but how does it scale when in a Redis Cluster ? I accept educated guesses on this. 2)

How can a Phoenix application tailored only to use channels scale on multiple machines? Using HAProxy? How to broadcast messages to all nodes?

此生再无相见时 提交于 2019-12-03 07:12:36
I use the node application purely for socket.io channels with Redis PubSub, and at the moment I have it spread across 3 machines, backed by nginx load balancing on one of the machines. I want to replace this node application with a Phoenix application, and I'm still all new to the erlang/Elixir world so I still haven't figured out how a single Phoenix application can span on more than one machine. Googling all possible scaling and load balancing terms yielded nothing. The 1.0 release notes mention this regarding channels: Even on a cluster of machines, your messages are broadcasted across the

RabbitMQ: How to specify the queue to publish to?

强颜欢笑 提交于 2019-12-03 06:36:36
RabbitMQ's Channel#basicConsume method gives us the following arguments: channel.basicConsume(queueName, autoAck, consumerTag, noLocal, exclusive, arguments, callback); Giving us the ability to tell RabbitMQ exactly which queue we want to consume from. But Channel#basicPublish has no such equivalency: channel.basicPublish(exchangeName, routingKey, mandatory, immediateFlag, basicProperties, messageAsBytes); Why can't I specify the queue to publish to here?!? How do I get a Channel publishing to, say, a queue named logging ? Thanks in advance! Basically queues can be binded to an exchange based

EmberJS actions - call one action from another when wrapped within `actions`

▼魔方 西西 提交于 2019-12-03 06:28:36
问题 How do you call one action from another action when wrapped within actions in an EmberJS controller? Original code that uses the now deprecated way to define actions: //app.js App.IndexController = Ember.ArrayController.extend({ // properties /* ... */ // actions actionFoo: function() { /* ... */ this.actionBar(); }, actionBar: function() { /* ... */ } }); //app.html <div class="foo" {{action actionFoo this}}> <div class="bar" {{action actionBar this}}> However, with EmberJS 1.0.0, we get a

Rails pub/sub with faye

*爱你&永不变心* 提交于 2019-12-03 06:20:55
问题 In a Rails app I've used Faye (Rack adapter) for push notifications (for chat). I want to use Faye for another use case (more push notifications) but I can't seem to figure it out. In my app a model can be created from a background job so I want to refresh one of my views (say the index action) when the model gets created. Like so: app/models/post.rb class Post include Mongoid::Document after_create :notify_subscribers private def notify_subscribers Faye::Client.publish("/posts") end end app