Hi,<div><br></div><div>I had developed a solution using rabbitmq and it was working fine. Then I started another instance of one of my apps on another machine and both instances stopped receiving messages. Here is more detail.</div>
<div><br></div><div>I have a setup with two fanout exchanges, call them e1 and e2. </div><div><br></div><div>I have two apps, one (call it a1) written in node-amqp and the other (a2) in python/pika.</div><div><br></div><div>
The workflow is:</div><div>1) a1 publishes a message to e1</div><div><br></div><div>2) a2 is listening to e1, receives the message , starts sending a series of messages to e2.</div><div><br></div><div>3) a1 is listening to e2 and prints out the messages it receives.</div>
<div><br></div><div>All 3 steps were working, then I added another instance of a1 on another machine and step 3 stopped working. Neither instance of a1 receives any more messages. rabbitmqctl tells me they are piling up in the queue, and a2 logs also tell me step 2 is still happening.</div>
<div><br></div><div>Specifically, the action that caused step 3 to fail was not simply adding another instance of a1 but having that instance do step 1.</div><div><br></div><div>Here are what I think are the relevant bits of code.</div>
<div><br></div><div>In a1:</div><div><div>var connection = amqp.createConnection({ host: 'broker_host' }); </div></div><div><div>connection.addListener('ready', function(){</div><div> //this is what I'm calling e1:</div>
<div> var from_web_exchange = connection.exchange('from_web_exchange', {type: 'fanout', autoDelete: false});</div><div> // and e2:</div><div> var from_worker_exchange = connection.exchange('from_worker_exchange', {type: 'fanout', autoDelete: false});</div>
<div> //hostname contains the name of the machine where this app is running. </div><div> //there will only be one instance of this app per machine</div><div> var queueName = hostname + "_queue";</div><div> var fromBuildersQueue = connection.queue(queueName, {exclusive: true}) </div>
<div> fromBuildersQueue.bind('from_worker_exchange', '#')</div></div><div><br></div><div><div> fromBuildersQueue.subscribe( {ack:true}, function(message){</div><div> sys.puts("got message: " + message.data.toString());</div>
</div><div> }</div><div> ...</div><div><br></div><div>//later:</div><div> var msg = "hello, world";</div><div><div> from_web_exchange.publish("#", msg); </div></div><div><br></div><div>
<br></div><div>in a2:</div><div><br></div><div># e1:</div><div><div>from_web_exchange = channel.exchange_declare(exchange="from_web_exchange",type="fanout")</div><div># e2:</div><div>from_worker_exchange = channel.exchange_declare(exchange="from_worker_exchange", type='fanout')</div>
<div><br></div><div>from_web_queue = channel.queue_declare(exclusive=True)</div><div>from_web_queue_name = from_web_queue.queue</div><div><br></div><div>channel.queue_bind(exchange='from_web_exchange', queue=from_web_queue_name)</div>
</div><div><br></div><div><div>def callback(ch, method, properties, body):</div></div><div> channel.basic_publish(exchange='from_worker_exchange',</div><div> routing_key="key.frombuilders",</div>
<div> body= "hello world from python")</div><div><br></div><div><div>channel.basic_consume(callback,</div><div> queue=from_web_queue.queue,</div><div> no_ack=True)</div>
<div><br></div><div>pika.asyncore_loop()</div></div><div><br></div><div>---</div><div>rabbitmqctl list_queues reports:</div><div><br></div><div><div>Listing queues ...</div><div>host1_queue<span class="Apple-tab-span" style="white-space:pre">        </span>7</div>
<div>amq.gen-AGnTMUOdr+DdImg0jfqahA==<span class="Apple-tab-span" style="white-space:pre">        </span>0</div><div>host2_queue<span class="Apple-tab-span" style="white-space:pre">        </span>0</div><div>...done.</div></div><div><br>
</div><div><br></div><div>Hope someone can tell me what is going on here. a1 is a web app and the first instance of it is on my local machine, and a2 represents me trying to deploy this app in a production environment.</div>
<div><br></div><div>Thanks!</div><div>Dan</div><div><br></div>