1.上传三个安装包
esl-erlang_17.3-1~centos~6_amd64.rpm
esl-erlang-compat-R14B-1.el6.noarch.rpm
rabbitmq-server-3.4.1-1.noarch.rpm
依次安装,前两个需要联网,最后一个本地安装
yum -y install esl-erlang_17.3-1~centos~6_amd64.rpm
yum -y install esl-erlang-compat-R14B-1.el6.noarch.rpm
rpm -ivh rabbitmq-server-3.4.1-1.noarch.rpm
2.配置
将配置文件模板复制到etc目录并编辑
cp /usr/share/doc/rabbitmq-server-3.4.1/rabbitmq.config.example /etc/rabbitmq/rabbitmq.config
vim /etc/rabbitmq/rabbitmq.config
修改某行loopback,注意去掉最后的逗号和前面的%注释
{loopback_users, []}
设置开机启动
chkconfig rabbitmq-server on
开启web管理页面并启动
rabbitmq-plugins enable rabbitmq_management
service rabbitmq-server start
然后在主机中通过地址:http://192.168.56.101:15672即可访问到管理界面,默认用户名密码都是guest
3.Docker配置
// 启动docker
systemctl start docker
// 下载docker镜像
docker pull rabbitmq:management
// 创建docker容器
docker run -di --name=name_rabbitmq -p 5671:5671 -p 5672:5672 -p 4369:4369 -p 15671:15671 -p 15672:15672 -p 25672:25672 rabbitmq:management
浏览器即可访问http://192.168.xxx.xxx:15672
4.使用说明
SpringMVC导包情况:
<!-- RabbitMQ -->
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
<version>1.4.5.RELEASE</version>
</dependency>
配置文件
mq.host=127.0.0.1
mq.username=queue
mq.password=1234
mq.port=8001
# 统一XML配置中易变部分的命名
mq.queue=test_mq
Spring整合RabbitMQ配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"