Skip to content

Instantly share code, notes, and snippets.

@ghiden
Created January 20, 2012 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghiden/1646101 to your computer and use it in GitHub Desktop.
Save ghiden/1646101 to your computer and use it in GitHub Desktop.
ruby and node.js message exchange via rabbitmq
require 'amqp'
EventMachine.run do
connection = AMQP.connect(:host => '127.0.0.1', :username => 'guest', :password => 'guest')
puts "Connecting to AMQP broker. Running #{AMQP::VERSION} version of the gem..."
channel = AMQP::Channel.new(connection)
queue = channel.queue("rubyqueue", :auto_delete => true)
exchange = channel.default_exchange
queue.subscribe do |payload|
puts "Received a message: #{payload}."
end
end
var amqp = require('amqp');
var connection = amqp.createConnection({ host: 'localhost' });
connection.on('ready', function () {
console.log('connected to ' + connection.serverProperties.product);
connection.exchange('').publish('rubyqueue', 'hello from js');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment