spring-boot-starter-amqp无法使用仅具有写许可权的用户凭据将消息发送到AMQP交换

问题描述 投票:0回答:1

我正在尝试从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>

我可以使用具有以下访问权限(读取,写入和配置)的用户凭据将消息发布到交换机:

user with configure access

但是当我使用如下没有配置权限的用户时,它将失败:

user without configure access

调用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尝试创建交换或检查交换是否存在(使用Admin API)。如果是这种情况,我们可以使用某些属性将其禁用吗?

spring-boot spring-amqp spring-rabbitmq spring-rabbit cloudamqp
1个回答
0
投票

要么删除任何Exchange/Queue/Binding @Bean,要么将shouldDeclare属性设置为false

© www.soinside.com 2019 - 2024. All rights reserved.