我正在尝试从 springboot 应用程序向 RabbitMQ 发送消息。使用的依赖项(springboot & amqp):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
<version>2.1.6.RELEASE</version>
</dependency>
我可以使用具有以下访问权限(读取、写入和配置)的用户凭据将消息发布到交换:
但是当我使用没有配置权限的用户时它会失败,如下所示:
调用时收到错误rabbitTemplate.convertAndSend(exchange, null, message);
:
CachingConnectionFactory : Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=403, reply-text=ACCESS_REFUSED - access to exchange 'MyExchangeName' in vhost 'my_vHost' refused for user 'my_user', class-id=40, method-id=10
我认为这是因为 Spring 它试图创建交换或检查交换是否存在(使用管理 API)。如果是这种情况,我们可以使用某些属性禁用它吗?