Created
January 20, 2012 08:16
-
-
Save ghiden/1646101 to your computer and use it in GitHub Desktop.
ruby and node.js message exchange via rabbitmq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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