<div class="gmail_quote"><div>Hi Ricardo,</div><div><br></div><div>There are several problems in your code, both on the sender and on the receiver side.</div><div><br></div><div>[sender]</div><div><br></div><div>If you use the library node-amqp provided here <a href="https://github.com/postwait/node-amqp">https://github.com/postwait/node-amqp</a>,</div>
<div>you may install it with npm  (the node package manager), using the following command in a shell:</div><div>$ npm install -g amqp</div><div>This will install the amqp library in the directory /lib/node_modules of your node installation directory.</div>
<div>Now, check that you have properly added  /lib/node_modules to your NODE_PATH.</div><div>If it is the case, your import is require(&#39;amqp&#39;) and not require(&#39;./amqp&#39;)</div><div><br></div><div>So here is the code you should use:</div>
<div><br></div><div><div>var amqp = require(&#39;amqp&#39;);</div><div><br></div><div>var connection = amqp.createConnection({ host: &#39;localhost&#39; });</div><div><br></div><div>// Wait for connection to become established.</div>
<div>connection.on(&#39;ready&#39;, function () {</div><div>   var x = connection.exchange()</div><div>   var q = connection.queue(&quot;aqueuename&quot;,</div><div>            { autoDelete: true, durable: false, exclusive: false });</div>
<div>   // Wait for the queue to be declared.<span class="Apple-tab-span" style="white-space:pre">        </span></div><div>   q.on(&#39;queueDeclareOk&#39;, function(){</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>x.publish(&#39;aqueuename&#39;, &quot;bar&quot;);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>connection.end();</div><div>   });</div><div>});</div></div><div><br></div><div><br></div><div>[receiver]</div><div><br></div><div>I hadn&#39;t ever use AsyncoreConnection, but you can use BlockingConnection :</div>
<div><br></div><div><br></div><div><div>#!/usr/bin/env python</div><div>import pika</div><div><br></div><div>connection = pika.BlockingConnection(pika.ConnectionParameters(host=&#39;localhost&#39;))</div><div>channel = connection.channel()</div>
<div><br></div><div>q = channel.queue_declare(queue=&#39;aqueuename&#39;,</div><div>                        auto_delete=True,</div><div>                        durable=False,</div><div>                        exclusive=False)</div>
<div><br></div><div>print &#39; [*] Waiting for messages. To exit press CTRL+C&#39;</div><div><br></div><div>def callback(ch, method, properties, body):</div><div>   print &quot; [x] Received %r&quot; % (body,)</div><div>
<br></div><div>channel.basic_consume(callback,</div><div>                     queue=&#39;aqueuename&#39;,</div><div>                     no_ack=True)</div><div><br></div><div>channel.start_consuming()</div></div><div><br>
</div><div><br></div><div>Cheers,</div><div>Gabriel</div><div><br></div><div><br></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); ">On 20/10/11 16:55, </span>Ricardo<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "> Brizido wrote:</span></div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">For some reason I can&#39;t get this example to work:<br>
<br>
<br>
[sender]<br>
var sys = require(&#39;sys&#39;);<br>
var amqp = require(&#39;./amqp&#39;);<br>
<br>
var connection = amqp.createConnection({ host: &#39;localhost&#39; });<br>
<br>
// Wait for connection to become established.<br>
connection.addListener(&#39;ready&#39;, function () {<br>
    var x = connection.exchange()<br>
    var q = connection.queue(&quot;aqueuename&quot;,<br>
             { autoDelete: true, durable: false, exclusive: false });<br>
    x.publish(&#39;aqueuename&#39;, {foo: &quot;bar&quot;});<br>
});<br>
<br>
[receiver]<br>
#!/usr/bin/env python<br>
import pika<br>
<br>
connection = pika.AsyncoreConnection(pika.ConnectionParameters(<br>
        host=&#39;localhost&#39;))<br>
channel = connection.channel()<br>
<br>
q = channel.queue_declare(queue=&#39;aqueuename&#39;,<br>
                         auto_delete=True,<br>
                         durable=False,<br>
                         exclusive=False)<br>
<br>
print &#39; [*] Waiting for messages. To exit press CTRL+C&#39;<br>
<br>
def callback(ch, method, properties, body):<br>
    print &quot; [x] Received %r&quot; % (body,)<br>
<br>
channel.basic_consume(callback,<br>
                      queue=&#39;aqueuename&#39;,<br>
                      no_ack=True)<br>
<br>
pika.asyncore_loop()<br>
<br>
<br>
I wanted to used a BlockingConnection. Do you know if this works with<br>
a BlockingConnection?<br>
<br>
<br>
Thanks<br>
<br>
Ricardo<br></blockquote></div>