You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by razeone <ra...@gmail.com> on 2013/07/12 03:45:57 UTC

AMQP and Node.js

Well, I have this Node.js application that uses STOMP to connect to ActiveMQ.
Everithing was cool until I needed better performance, and que STOMP
implementations in Node.js are more like personal projects.

So, looking for the ActiveMQ documentation, I realized that it supports now
AMQP and I decided to change to this protocol.

The issue is that I cannot connect to the broker, I have setted up and
configure it but I don't get the connection.

I'm trying with and without the credentials, the explicit port, the url, and
it just not works, there's somebody already did this?

With the same client I'm always get connected to RabbitMQ, and that's a good
start, I think. This is my actual code:

var amqp = require('amqp');

var conn = amqp.createConnection({host: "10.193.2.29:5672"},
                        {defaultExchangeName: "my-queue"});

// Wait for connection to become established.
conn.on('ready', function () {
     console.log('Im now connected');  
     // Use the default 'amq.topic' exchange
     var q = conn.queue('my-queue', function (queue) {
           console.log('Queue ' + queue.name + ' is open');
    });
});


Regards, Jorge.




--
View this message in context: http://activemq.2283324.n4.nabble.com/AMQP-and-Node-js-tp4669165.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: AMQP and Node.js

Posted by Gordon Sim <gs...@redhat.com>.
On 07/15/2013 08:55 PM, James Carr wrote:
> I would raise an issue on the original github project so it can get added.

That is certainly a good idea...

> node-amqp should be a one stop place for working with amqp rather than
> having to make a bunch of modules for each concrete implementation.

...and this would be great.

The only issue is that node-amqp supports an old version of AMQP and the 
difference between that and 1.0 is pretty significant. It would not be a 
small amount of work to update it and it would likely affect the current 
API which is quite 0-8/0-9-1 specific.

What would be even better in some ways would be a common JS API for 
which different protocols (AMQP, MQTT, STOMP) or implementations were 
available and which you could use either from node or over websockets in 
the browser.

Re: AMQP and Node.js

Posted by James Carr <ja...@gmail.com>.
I would raise an issue on the original github project so it can get added.
node-amqp should be a one stop place for working with amqp rather than
having to make a bunch of modules for each concrete implementation.


On Mon, Jul 15, 2013 at 2:48 PM, Christian Posta
<ch...@gmail.com>wrote:

> You can pass a "jms style" selector in the AMQP message with the header key
> of "'jms-selector" and ActiveMQ will observe the selector for your
> consumer. However, the particular node project referenced by Gordon does
> not allow you to set custom headers on the subscribe frame. Might be able
> to hack it in somehow.
>
>
> On Mon, Jul 15, 2013 at 1:46 PM, razeone <ra...@gmail.com> wrote:
>
> > Thanks a lot Gordon, your answer gave me a very good alternative to STOMP
> > and
> > it looks like works fine. Now I have been connected, the question I have
> > now
> > is:
> >
> > How do I establish content based routing? I mean, pass selector headers,
> it
> > is possible with AMQP?
> >
> > I really appreciate your help :)
> >
> >
> >
> > --
> > View this message in context:
> >
> http://activemq.2283324.n4.nabble.com/AMQP-and-Node-js-tp4669165p4669308.html
> > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> >
>
>
>
> --
> *Christian Posta*
> http://www.christianposta.com/blog
> twitter: @christianposta
>

Re: AMQP and Node.js

Posted by Christian Posta <ch...@gmail.com>.
You can pass a "jms style" selector in the AMQP message with the header key
of "'jms-selector" and ActiveMQ will observe the selector for your
consumer. However, the particular node project referenced by Gordon does
not allow you to set custom headers on the subscribe frame. Might be able
to hack it in somehow.


On Mon, Jul 15, 2013 at 1:46 PM, razeone <ra...@gmail.com> wrote:

> Thanks a lot Gordon, your answer gave me a very good alternative to STOMP
> and
> it looks like works fine. Now I have been connected, the question I have
> now
> is:
>
> How do I establish content based routing? I mean, pass selector headers, it
> is possible with AMQP?
>
> I really appreciate your help :)
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/AMQP-and-Node-js-tp4669165p4669308.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Re: AMQP and Node.js

Posted by Gordon Sim <gs...@redhat.com>.
On 07/15/2013 06:46 PM, razeone wrote:
> Thanks a lot Gordon, your answer gave me a very good alternative to STOMP and
> it looks like works fine. Now I have been connected, the question I have now
> is:
>
> How do I establish content based routing? I mean, pass selector headers, it
> is possible with AMQP?

It is certainly possible with AMQP (you set a filter on the attach 
frame), but as Christian points out, the Messenger API from Qpid Proton 
which this project wraps does not expose that ability.


Re: AMQP and Node.js

Posted by razeone <ra...@gmail.com>.
Thanks a lot Gordon, your answer gave me a very good alternative to STOMP and
it looks like works fine. Now I have been connected, the question I have now
is: 

How do I establish content based routing? I mean, pass selector headers, it
is possible with AMQP?

I really appreciate your help :)



--
View this message in context: http://activemq.2283324.n4.nabble.com/AMQP-and-Node-js-tp4669165p4669308.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: AMQP and Node.js

Posted by Gordon Sim <gs...@redhat.com>.
On 07/12/2013 05:00 PM, Gordon Sim wrote:
> On 07/12/2013 02:45 AM, razeone wrote:
>> Well, I have this Node.js application that uses STOMP to connect to
>> ActiveMQ.
>> Everithing was cool until I needed better performance, and que STOMP
>> implementations in Node.js are more like personal projects.
>>
>> So, looking for the ActiveMQ documentation, I realized that it
>> supports now
>> AMQP and I decided to change to this protocol.
>>
>> The issue is that I cannot connect to the broker, I have setted up and
>> configure it but I don't get the connection.
>>
>> I'm trying with and without the credentials, the explicit port, the
>> url, and
>> it just not works, there's somebody already did this?
>>
>> With the same client I'm always get connected to RabbitMQ, and that's
>> a good
>> start, I think. This is my actual code:
>>
>> var amqp = require('amqp');
>>
>> var conn = amqp.createConnection({host: "10.193.2.29:5672"},
>>                          {defaultExchangeName: "my-queue"});
>>
>> // Wait for connection to become established.
>> conn.on('ready', function () {
>>       console.log('Im now connected');
>>       // Use the default 'amq.topic' exchange
>>       var q = conn.queue('my-queue', function (queue) {
>>             console.log('Queue ' + queue.name + ' is open');
>>      });
>> });
>
> Unfortunately that is a protocol version issue. ActiveMQ supports AMQP
> 1.0. Priori to this being released AMQP had a couple of earlier releases
> that were in effect entirely different protocols. The implementation you
> are using here implements the 0-8/0-9-1 version of AMQP so won't work
> against a 1.0 implementation.

One other node.js implementation I am aware of (but have never actually 
tried myself), that speaks AMQP 1.0 is 
https://github.com/pofallon/node-qpid, just in case you want to have a 
look at it. (Page reports that it has been run against ActiveMQ 5.8s 
AMQP support)


Re: AMQP and Node.js

Posted by Gordon Sim <gs...@redhat.com>.
On 07/12/2013 02:45 AM, razeone wrote:
> Well, I have this Node.js application that uses STOMP to connect to ActiveMQ.
> Everithing was cool until I needed better performance, and que STOMP
> implementations in Node.js are more like personal projects.
>
> So, looking for the ActiveMQ documentation, I realized that it supports now
> AMQP and I decided to change to this protocol.
>
> The issue is that I cannot connect to the broker, I have setted up and
> configure it but I don't get the connection.
>
> I'm trying with and without the credentials, the explicit port, the url, and
> it just not works, there's somebody already did this?
>
> With the same client I'm always get connected to RabbitMQ, and that's a good
> start, I think. This is my actual code:
>
> var amqp = require('amqp');
>
> var conn = amqp.createConnection({host: "10.193.2.29:5672"},
>                          {defaultExchangeName: "my-queue"});
>
> // Wait for connection to become established.
> conn.on('ready', function () {
>       console.log('Im now connected');
>       // Use the default 'amq.topic' exchange
>       var q = conn.queue('my-queue', function (queue) {
>             console.log('Queue ' + queue.name + ' is open');
>      });
> });

Unfortunately that is a protocol version issue. ActiveMQ supports AMQP 
1.0. Priori to this being released AMQP had a couple of earlier releases 
that were in effect entirely different protocols. The implementation you 
are using here implements the 0-8/0-9-1 version of AMQP so won't work 
against a 1.0 implementation.