当我尝试向 rabbitmq 默认交换发布消息时,我收到错误消息:“ACCESS_REFUSED - 默认交换不允许操作”
我用
symfony old_rabbit_mq.yaml 中的生产者配置:
producers:
default.exchange:
class: App\Producer\DefaulExchangeProducer
connection: default
exchange_options: {name: '', type: direct}
用于推送消息的Scritp:
class PublishToQueueCommand extends Command
{
protected static $defaultName = 'app:publish-to-queue';
private $producer;
public function __construct(DefaulExchangeProducer $producer)
{
$this->producer = $producer;
parent::__construct();
}
protected function configure()
{
$this
->setDescription('Publishes a message to a queue');
;
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
// Publish the message to the queue
$this->producer->publish('my message', 'my_queue');
return 1;
}
}
rabbitmq 服务器中用户的虚拟主机权限:
配置正则表达式.,写入正则表达式.,读取正则表达式.*
我可以从 rabbitmq web 界面做到这一点。