(reply-code=403, reply-text=ACC">
摘要:问题一:
为了授权该用户对VirtualHost\"/\" 的访问,用户添加之后,需要对该用户进行授权,不然运行会出现错误:
1 Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; reason: {#method
为了授权该用户对VirtualHost"/" 的访问,用户添加之后,需要对该用户进行授权,不然运行会出现错误:
1 Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; reason: {#method<channel.close>(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<channel.close>(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<channel.close>(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<channel.close>(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重启,队列则被删除,与现有这个队列的方式保持一致。
相关文章推荐
虚拟主机的专业参数,分别都是什么意思?2022-09-09
中非域名注册规则是怎样的?注册域名有什么用处? 2022-01-10
HostEase新年活动促销 美国/香港主机全场低至五折2021-12-28
HostGator下载完整备份教程分享2021-12-28
Flink中有界数据与无界数据的示例分析2021-12-28