[rabbitmq-discuss] getting node.js to talk to scala over rabbitmq

9 views
Skip to first unread message

Meredith Gregory

unread,
Oct 24, 2011, 7:50:07 PM10/24/11
to rabbitmq...@lists.rabbitmq.com
Dear Rabbiters,

i'm running into a problem getting node.js to talk to scala over rabbitmq. i'm using the node-amqp package with node.js. i installed it using npm install amqp. i'm using the java client for rabbitmq 2.5.1 on the scala side. i've successfully gotten scala to talk to scala and node.js to talk to node.js. However, when i attempt to get node.js to talk to scala there appears to be a disagreement regarding queue declaration. Thus, if i fire up node.js first and look at the queue it creates with the rabbitmq management plugin i see


i then attempt to accomplish a connection from the scala side (with code that works on scala-to-scala) and i see an exception when the code calls the queueDeclare method.

            channel.exchangeDeclare( exQNameRoot, "direct" )
            //channel.queueDeclare(qname, true, false, false, null);
   channel.queueDeclare(qname, true, false, true, null); // <-- here we throw an exception

java.io.IOException
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:107)
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:131)
at com.rabbitmq.client.impl.ChannelN.queueDeclare(ChannelN.java:627)
at com.rabbitmq.client.impl.ChannelN.queueDeclare(ChannelN.java:59)
at com.biosimilarity.lift.lib.AMQPBrokerScope$StdMonadicAMQPSndrRcvr.sender(AMQPMnd.scala:53)

Any help would be most welcome!

Best wishes,

--greg

--
L.G. Meredith
Managing Partner
Biosimilarity LLC
7329 39th Ave SW

Alvaro Videla

unread,
Oct 24, 2011, 7:56:44 PM10/24/11
to Meredith Gregory, rabbitmq...@lists.rabbitmq.com
Hi,

On Oct 25, 2011, at 1:50 AM, Meredith Gregory wrote:

    channel.queueDeclare(qname, true, false, true, null); // <-- here we throw an exception

As a first look it seems that you are declaring the same queue but with different options. I think your node.js declared queue is "auto_delete" and "durable". I don't know what the Scala code options are but make sure they are the same.

Cheers,

Alvaro

Simon MacMullen

unread,
Oct 25, 2011, 5:47:27 AM10/25/11
to rabbitmq...@lists.rabbitmq.com
On 25/10/11 00:50, Meredith Gregory wrote:
> Dear Rabbiters,
>
> i'm running into a problem getting node.js to talk to scala over
> rabbitmq. i'm using the node-amqp package with node.js. i installed it
> using npm install amqp. i'm using the java client for rabbitmq 2.5.1 on
> the scala side. i've successfully gotten scala to talk to scala
> and node.js to talk to node.js. However, when i attempt to get node.js
> to talk to scala there appears to be a disagreement regarding
> queue declaration. Thus, if i fire up node.js first and look at the
> queue it creates with the rabbitmq management plugin i see
>
>
>
> node-simple-direct_queue
> <http://localhost:55672/mgmt/#/queues/%2F/node-simple-direct_queue>
> AD Idle 0 0 0

So this looks like a transient autodelete queue.

> i then attempt to accomplish a connection from the scala side (with code
> that works on scala-to-scala) and i see an exception when the code calls
> the queueDeclare method.
>
> channel.exchangeDeclare( exQNameRoot, "direct" )
> //channel.queueDeclare(qname, true, false, false, null);
> channel.queueDeclare(qname, true, false, true, null); // <-- here we
> throw an exception

And here you are declaring a durable autodelete queue. That's probably
your problem.

> java.io.IOException
> at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:107)
> at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:131)
> at com.rabbitmq.client.impl.ChannelN.queueDeclare(ChannelN.java:627)
> at com.rabbitmq.client.impl.ChannelN.queueDeclare(ChannelN.java:59)
> at
> com.biosimilarity.lift.lib.AMQPBrokerScope$StdMonadicAMQPSndrRcvr.sender(AMQPMnd.scala:53)

...but you can unwrap this exception and check, or look in the broker
logs to see what it's complaining about.

Cheers, Simon

--
Simon MacMullen
RabbitMQ, VMware
_______________________________________________
rabbitmq-discuss mailing list
rabbitmq...@lists.rabbitmq.com
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

Meredith Gregory

unread,
Oct 25, 2011, 12:45:37 PM10/25/11
to Simon MacMullen, rabbitmq...@lists.rabbitmq.com
Dear Simon, et al,

Thanks! Yes, i spotted it almost immediately after i sent the email. ;-) The two are happily chatting, now.

Best wishes,

--greg

Meredith Gregory

unread,
Oct 27, 2011, 4:46:27 PM10/27/11
to Simon MacMullen, rabbitmq...@lists.rabbitmq.com
Dear Rabbiters,

A follow on query. It appears that with the node.js node-amqp client i need only set the content type to have the content encoding handled more or less appropriately. In the java client the default seems to be octet stream. Is there an encoding service underneath basicPublish / basicConsume that is utilizing the info on the content type properties or is that a feature of a given client offering (such as node-amqp)? 

Best wishes,

--greg

Michael Klishin

unread,
Oct 27, 2011, 5:29:51 PM10/27/11
to Meredith Gregory, rabbitmq...@lists.rabbitmq.com
Meredith Gregory:

> Is there an encoding service underneath basicPublish / basicConsume that is utilizing the info on the content type properties or is that a feature of a given client offering (such as node-amqp)?

It is a feature offered by node-amqp (and an opinionated one). You can subclass com.rabbitmq.client.DefaultConsumer and
make your implementation assume all message payloads are JSON and thus can be deserialized automatically. As far as AMQP clients are concerned, message payloads are just collections of bytes, your applications decide how to interpret them.

MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

Reply all
Reply to author
Forward
0 new messages