ubtuntu 安装
echo 'deb http://www.rabbitmq.com/debian/ testing main' | sudo tee /etc/apt/sources.list.d/rabbitmq.list
wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install rabbitmq-server
配置
下载配置文件,放在 /etc/rabbitmq/rabbitmq.config
打开注释来允许远程连接
{loopback_users, []},
重启服务
sudo rabbitmqctl restart
更改 guset 用户密码
rabbitmqctl change_password guest new_pass
Hello world
require "bunny"
conn = Bunny.new("amqp://guest:guest@localhost:5672")
conn.start
ch = conn.create_channel
fa = c.fanout("test")
publish "hello"
require 'sneakers'
require 'json'
Sneakers.configure :amqp => "amqp://guest:520Share99@120.76.244.65:5672"
class Processor
include Sneakers::Worker
from_queue "abc"
def work(msg)
puts msg
ack!
end
end