RabbitMQ安装与配置

阅读更多

一、安装Rabbit MQ

 

1. 下载并安装Erlang:http://www.erlang.org/downloads

2. 下载并安装Rabbit MQ:http://www.rabbitmq.com/releases/rabbitmq-server/

 

    默认安装的Rabbit MQ 监听端口是15672

 

二、Rabbit MQ配置和运行

 

1. 激活管理插件

    切换到sbin目录下,执行:rabbitmq-plugins enable rabbitmq_management

    重启服务使其生效:net stop RabbitMQ && net start RabbitMQ

 

2. 创建用户

    创建用户admin,密码为admin123:rabbitmqctl add_user admin admin123

    给admin赋予管理员administrator角色:rabbitmqctl set_user_tags admin administrator

    查看用户列表:rabbitmqctl list_users

    创建vhost:rabbitmqctl add_vhost /myhost

    查看vhost:rabbitmqctl list_vhosts

    赋予用户admin具有/myhost这个virtual host中所有资源的配置、写、读权限以便管理其中的资源: rabbitmqctl  set_permissions -p /myhost  admin '.*' '.*' '.*'  

 

 

常见问题

1. 支持使用IP访问

    在etc\rabbitmq.config.example中增加如下配置:

    {tcp_listeners, [15672]},

    {loopback_users, ["admin"]},

2. 报如下异常

org.springframework.context.ApplicationContextException: Failed to start bean 'amqpTemplate.replyListener'; nested exception is org.springframework.amqp.AmqpIllegalStateException: Fatal exception on listener startup

Caused by: org.springframework.amqp.AmqpIllegalStateException: Fatal exception on listener startup

Caused by: org.springframework.amqp.rabbit.listener.FatalListenerStartupException: Cannot prepare queue for listener. Either the queue doesn't exist or the broker will not allow us to use it.

Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; reason: {#method(reply-code=404, reply-text=NOT_FOUND - no queue '93bbbad7-4dcd-4f2c-930f-30f1fca50a26' in vhost '/xjsit', class-id=50, method-id=10), null, ""}

 

解决:访问http://localhost:15672/,在Admin页签中给用户设置相应配置和读写的权限。

你可能感兴趣的:(RabbitMQ,消息,mq,异步)