[rabbitmq-discuss] RabbitMQ message filtering based on routing key

s_kan sathish.kannath at wipro.com
Thu Feb 6 07:46:29 GMT 2014


Hi All,

I am working on an application with NodeJS and RabbitMQ. I ve a client which
is a browser, and when it connects to server (Node.js+Socket.io
application), i want to look up from the queue with a particular routing
key.

Ex : publisher publishes with routing keys fail.user1.message and
fail.user2.message to a general queue fail.queue and fail.queue is bound to
fail.exchange ( It is topic based ) . Now when user1 connects, he is
interested only in fail.user1.message, similarly for user2.

I would like to know, if this is possible?, currently my subscriber is
taking both fail.user1 and fail.user2.message from the context of user1. I
am not using multiple queues as there will be  lot of users. I am looking to
filter out the message

Sample Code for subscriber 

var failExchange = connection.exchange('fail.exchange', {passive:true});

var failQueue = connection.queue('fail.queue',{passive :
true},function(queue){
      
      });

 failQueue.bind('fail.exchange','fail.'+userId+'.message',function(){
        console.log('binding complete'+userId);
      });
  
  failQueue.subscribe(function(message, headers, deliveryInfo){
         .... // Here iam getting all the routing keys in deliveryInfo, how
can i tell iam interested only in  //fail.user1.message
        });

Any help/ideas?

Thanks



--
View this message in context: http://rabbitmq.1065348.n5.nabble.com/RabbitMQ-message-filtering-based-on-routing-key-tp33136.html
Sent from the RabbitMQ mailing list archive at Nabble.com.


More information about the rabbitmq-discuss mailing list