消息中间件RabbitMQ-实战一

1.安装erlang环境
http://www.erlang.org/downloads
apt-get install erlang
yum install erlang
2.安装rabbitmq
apt-get install rabbitmq-server
http://www.rabbitmq.com/download.html
3.创建用户
(自己编译rabbitmq-server下的操作)
cd /opt/rabbitmq-server-3.6.10/deps/rabbit/scripts
./rabbitmqctl add_user rabbit 111111
/rabbitmqctl set_permissions -p "/" rabbit ".*" ".*" ".*"
./rabbitmqctl list_users
./rabbitmqctl list_permissions
4.C语言客户端RabbitMQ C client
http://www.rabbitmq.com/devtools.html
https://github.com/alanxz/rabbitmq-c
修改默认用户guest,改为 rabbit 111111 (guest只支持localhost本机访问,不支持互联网)
amqp_listen.c
amqp_sendstring.c
make
5.验证
broker启动./rabbitmq-server start (/etc/rabbitmq/rabbitmq-env.conf 可修改默认端口5672)
publisher发送./examples/amqp_sendstring 106.14.98.251 5689 amq.direct rabbit "i love erlang"
consumer接收./examples/amqp_listen 106.14.98.251 5689 amq.direct rabbit
接收打印
Delivery 1, exchange amq.direct routingkey rabbit
Content-type: text/plain
----
00000000: 69 20 6C 6F 76 65 20 65 : 72 6C 61 6E 67 i love erlang
0000000D:

管理控制台

用户名需 rabbitmqctl set_user_tags test administrator 否则登录不了

cd /opt/rabbitmq-server-3.6.10/deps/rabbit/scripts

vi rabbitmq-env 第一行 添加 RABBITMQ_PLUGINS_DIR=../../../plugins/

export PATH=$PATH:.

rabbitmq-plugins enable rabbitmq_management

rabbitmq-plugins list


http://106.14.11.11:15672

消息中间件RabbitMQ-实战一_第1张图片


消息中间件RabbitMQ-实战一_第2张图片



你可能感兴趣的:(消息中间件)