fun with nodejs and rabbitmq

The long awaited server side javascript revolutions is alive and well!

Here is a quickstart for funning around with nodejs and rabbitmq

The copy-pasta is from my retro machine at the house running ubuntu 10 (Maverick), but there’s little ubuntu specific stuff…

install nodejs

 % git clone https://github.com/joyent/node.git
 % cd node
 % sudo apt-get install g++ libssl-dev
 % ./configure && make && sudo make install
 % echo 'console.log( "go node!" )'  | node

install npm

As per the website, you can run the install script from curl.

Oddly enuff, to avoid running it as root, buddy suggests making your user own all of /usr/local.

Instead, I thought I’d add an npm user and setuid the npm stuff:

 % sudo adduser --gid 0 npm
 % sudo chmod g+w /usr/local/lib 
 % sudo chmod g+w /usr/local/share/man 
 % sudo chmod g+w /usr/local/bin 
 % sudo chmod g+w /usr/local/man/man1
 % sudo su npm
 % cd /tmp
 % git clone https://github.com/isaacs/npm.git
 % cd npm
 % ./configure
 % make && make install 
I tried setting 4755 on /usr/local/lib/node_modules/npm/bin/npm.js, but it complains when I tried to install some stuff..

Just have to use the npm user to install node-amqp:

 % sudo su npm -c "npm install -g amqp"
 % cd 
 % ln -s /usr/local/lib/node_modules

install rabbitmq

The out of the box rabbit for ubu10 was ancient bullshit!

The rabbitmq guys have some tips… basically:

 % echo deb http://www.rabbitmq.com/debian/ testing main | sudo tee -a /etc/apt/sources.list
 % wget http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
 % sudo apt-key add rabbitmq-signing-key-public.asc
 % sudo apt-get update
 % sudo apt-get install rabbitmq-server

It gets cranked up at install and there is a handy init script:

 % sudo /etc/init.d/rabbitmq-server status

a simple demo

So… this code runs fine on my mac, but is weirdly busted on my olde ubuntu box:

clear ; ./amqp-dee-dum.js
connected
ready
got the exchange
[hilarity ensues: try it out!]

I had to create new exchange named ‘tmp’, it wouldn’t let me use ‘amq.direct’ for some reason…

Anyhooo…

I think the code is pretty ez to follow if sorta copy-pasta heavy.

I hope to do a refactored version at some point…

what happened with the old rabbit

connected
ouch: Oversized frame 1342243080
cya!
FATAL ERROR: v8::Object::SetIndexedPropertiesToExternalArrayData() length exceeds max acceptable value

Using the non-crusty version everything worked fine.

Advertisements

2 Comments »

  1. I just spent an hour debugging this exact issue – turns out, my Ubuntu server was running an old version of RabbitMQ Client which expects version ~0.8 of AMQP, and node-amqp expects version ~0.9

    In short, add the RabbitMQ repos to your apt sources then apt-get upgrade / update

  2. brianin3d said

    Nice! I finally did get around to this… Updated the post…

RSS feed for comments on this post · TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: