Rabbitmq遇到的问题-成都快上网建站

Rabbitmq遇到的问题

问题一:

为了授权该用户对VirtualHost"/" 的访问,用户添加之后,需要对该用户进行授权,不然运行会出现错误:

十载的周村网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整周村建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。成都创新互联从事“周村网站设计”,“周村网站推广”以来,每个客户项目都认真落实执行。

1 Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; reason: {#method(reply-code=403, reply-text=ACCESS_REFUSED - access to queue \'hello\' in vhost \'/\' refused for user \'admin\', class-id=50, method-id=10), null, ""}

详细错误日志为: java.io.IOException at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:106) at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:102) at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:124) at com.rabbitmq.client.impl.ChannelN.queueDeclare(ChannelN.java:766) at com.rabbitmq.client.impl.ChannelN.queueDeclare(ChannelN.java:61) at com.asiainfo.mq.rabbitmq.rabbitmqtest.SendTest.main(SendTest.java:29) Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; reason: {#method(reply-code=403, reply-text=ACCESS_REFUSED - access to queue \'hello\' in vhost \'/\' refused for user \'admin\', class-id=50, method-id=10), null, ""} at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:67) at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:33) at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:343) at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:216) at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:118) ... 3 more Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; reason: {#method(reply-code=403, reply-text=ACCESS_REFUSED - access to queue \'hello\' in vhost \'/\' refused for user \'admin\', class-id=50, method-id=10), null, ""} at com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:473) at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:313) at com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(AMQChannel.java:144) at com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:91) at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:533)

操作过程为:在Admin标签页下点击新增的用户"admin",进入授权页面,默认直接点击"set permission"即可:

用户以及授权添加完成之后,在rabbitmq.config.example文件中,添加以下内容,保存后重启RabbitMQ服务:

……
[
{rabbit,
[%%
%% Network Connectivity
%% ====================
%%
%% By default, RabbitMQ will listen on all interfaces, using
%% the standard (reserved) AMQP port.
%%
{tcp_listeners, [5672]},
{loopback_users, ["admin"]},
……
]}
].

在浏览器中输入http://192.168.0.124:15672实现通过IP地址访问,成功登录:

解决方法二:

原因:
用户‘admin’没有权限访问‘/’

sudo rabbitmqctl list_users
列出用户权限
Listing users ...
mq [administrator]
guest [administrator]

# rabbitmqctl set_permissions -p VHostPath【虚拟主机路径 ‘/’】 User【用户名字】 ".*" ".*" ".*"
sudo rabbitmqctl set_permissions -p / mq \'.*\' \'.*\' \'.*\'
该命令使用户mq具有‘/’这个virtual host中所有资源的配置、写、读权限以便管理其中的资源

# /etc/init.d/rabbitmq-server restart

问题二:

Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg \'durable\' for queue \'hello\' in vhost \'/\': received \'true\' but current is \'false\', class-id=50, method-id=10)

boolean duarble = true; channel.queueDeclare(QUEUE_NAME,duarble,false,false,null);

因为现在队列已经存在,并且设置的rabbitmq重启后,队列信息不会持久化,现在设置的channel链接队列的匹配信息不正确 ,所以将duarble 设置为 false ,代表rabbitmq重启,队列则被删除,与现有这个队列的方式保持一致。


分享名称:Rabbitmq遇到的问题
标题来源:http://kswjz.com/article/cpgogi.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流