Hi,<div><br></div><div>I am new to rabbitmq. I got the python "getting started" examples to work just fine.</div><div>I would like to be able to send messages between node.js (using node.amqp) and python/pika.</div>
<div><br></div><div>I can successfully receive a message in node.js using this code:</div><div><br></div><div>[receiver - node.js]</div><div><div><font class="Apple-style-span" face="'courier new', monospace">var sys = require('sys');</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">var amqp = require('./amqp');</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div>
<font class="Apple-style-span" face="'courier new', monospace">var connection = amqp.createConnection({ host: 'localhost' });</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br>
</font></div><div><font class="Apple-style-span" face="'courier new', monospace">// Wait for connection to become established.</font></div><div><font class="Apple-style-span" face="'courier new', monospace">connection.addListener('ready', function () {</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> // Create a queue and bind to all messages.</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> // Use the default 'amq.topic' exchange</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace"> var q = connection.queue('my-queue');</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> // Catch all messages</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> q.bind('#');</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> </font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace"> // Receive messages</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> q.subscribe(function (message) {</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> // Print messages to stdout</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> sys.puts(sys.inspect(message));</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> });</font></div><div>
<font class="Apple-style-span" face="'courier new', monospace">});</font></div><div><br></div><div>[sender - python/pika]</div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">#!/usr/bin/env python</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">import pika</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">connection = pika.AsyncoreConnection(pika.ConnectionParameters(</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> host='localhost'))</font></div><div><font class="Apple-style-span" face="'courier new', monospace">channel = connection.channel()</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">channel.basic_publish(exchange='',</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> routing_key='my-queue',</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> body='Hello World!')</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">print " [x] Sent 'Hello World!'"</font></div><div><font class="Apple-style-span" face="'courier new', monospace">connection.close()</font></div>
</div><div><br></div><div>But I can't go the other way. I'm not sure that the message sent by node.js is going anywhere. I've looked at the unit tests for node.amqp (they all pass) but there is something I am missing, probably to do with exchanges or something. I'd like to do something like this:</div>
<div><br></div><div>[sender - node.js]</div><div><div><font class="Apple-style-span" face="'courier new', monospace">var sys = require('sys');</font></div><div><font class="Apple-style-span" face="'courier new', monospace">var amqp = require('./amqp');</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">var connection = amqp.createConnection({ host: 'localhost' });</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">// Wait for connection to become established.</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">connection.addListener('ready', function () {</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> // Create a queue and bind to all messages.</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> // Use the default 'amq.topic' exchange</font></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; "> connection.publish("my-queue", {random_key:"this is my message"});</span></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> connection.end();</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> </font></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">});</span></div>
<div><br></div><div>[receiver - python/pika]</div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">#!/usr/bin/env python</font></div><div><font class="Apple-style-span" face="'courier new', monospace">import pika</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">import sys</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">connection = pika.AsyncoreConnection(pika.ConnectionParameters(</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> host='localhost'))</font></div><div><font class="Apple-style-span" face="'courier new', monospace">channel = connection.channel()</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">print ' [*] Waiting for messages. To exit press CTRL+C'</span></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">def callback(ch, method, properties, body):</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> print body,</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> sys.stdout.flush()</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">channel.basic_consume(callback,</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> queue='my-queue',</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> no_ack=True)</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div>
<font class="Apple-style-span" face="'courier new', monospace">pika.asyncore_loop()</font></div></div><div><br></div><div>But nothing happens.</div><div><br></div><div>Another thing (possibly related?) that I run into is if I create a queue in python using, e.g.:</div>
<div><br></div><div><font class="Apple-style-span" face="'courier new', monospace">channel.queue_declare(queue='hello')</font></div><div><br></div><div>Then, in node.js, when I do:</div><div><br></div><div>
<div><font class="Apple-style-span" face="'courier new', monospace"> var q = connection.queue('hello');</font></div></div><div><br></div><div>I get this:<br><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace">Unhandled channel error: PRECONDITION_FAILED - parameters for queue 'hello' in vhost '/' not equivalent</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">events:12</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> throw arguments[1];</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> ^</font></div><div><font class="Apple-style-span" face="'courier new', monospace">Error: PRECONDITION_FAILED - parameters for queue 'hello' in vhost '/' not equivalent</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> at Queue._onMethod (/Users/dtenenba/dev/dev-amqp/node-amqp/amqp.js:1390:15)</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> at Connection._onMethod (/Users/dtenenba/dev/dev-amqp/node-amqp/amqp.js:784:28)</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> at AMQPParser.onMethod (/Users/dtenenba/dev/dev-amqp/node-amqp/amqp.js:698:12)</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> at AMQPParser._parseMethodFrame (/Users/dtenenba/dev/dev-amqp/node-amqp/amqp.js:415:10)</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> at AMQPParser.execute (/Users/dtenenba/dev/dev-amqp/node-amqp/amqp.js:196:20)</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> at Connection.<anonymous> (/Users/dtenenba/dev/dev-amqp/node-amqp/amqp.js:731:12)</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> at Connection.emit (events:31:17)</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> at IOWatcher.callback (net:489:16)</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> at node.js:773:9</font></div></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><meta charset="utf-8"><span class="Apple-style-span" style="font-family: arial; ">It appears that python's idea of a 'hello' queue is different from that of node.amqp's. How can I do this so that I don't receive this error?</span></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-style-span" style="font-family: arial; ">Hope this is the right place for this question. If not please tell me where I should post it.</span></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-style-span" style="font-family: arial; ">Thanks</span></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-style-span" style="font-family: arial; ">Dan</span></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-style-span" style="font-family: arial; "><br></span></font></div>