当前位置:   article > 正文

Rabbitmq遇到的问题

cshutdownsignalexception access to queue

问题一:

  为了授权该用户对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, ""}

  1. 详细错误日志为:
  2. java.io.IOException
  3. at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:106)
  4. at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:102)
  5. at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:124)
  6. at com.rabbitmq.client.impl.ChannelN.queueDeclare(ChannelN.java:766)
  7. at com.rabbitmq.client.impl.ChannelN.queueDeclare(ChannelN.java:61)
  8. at com.asiainfo.mq.rabbitmq.rabbitmqtest.SendTest.main(SendTest.java:29)
  9. 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, ""}
  10. at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:67)
  11. at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:33)
  12. at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:343)
  13. at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:216)
  14. at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:118)
  15. ... 3 more
  16. 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, ""}
  17. at com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:473)
  18. at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:313)
  19. at com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(AMQChannel.java:144)
  20. at com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:91)
  21. at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:533)

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

RabbitMQ远程不能访问问题的解决

用户以及授权添加完成之后,在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地址访问,成功登录:

RabbitMQ远程不能访问问题的解决

解决方法二:

原因:
用户‘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)

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

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

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

转载于:https://my.oschina.net/LucasZhu/blog/1537430

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/639283
推荐阅读
相关标签
  

闽ICP备14008679号