简体   繁体   English

无法将 RabbitMQ 消息发布到具有自己名称的队列

[英]Can't publish RabbitMQ message to queue with own name

I would like to publish a rabbitMQ message to a queue with this name: "vincent.test.rabbitMq".我想将一条 rabbitMQ 消息发布到这个名称的队列:“vincent.test.rabbitMq”。 Im trying to do that with the Symfony-messenger.我正在尝试使用 Symfony-messenger 来做到这一点。 This is my Message:这是我的信息:

class TestMessage
{
    private string $value;

    /**
     * @param string $value
     */
    public function __construct(string $value)
    {
        $this->value = $value;
    }

    /**
     * @return string
     */
    public function getValue(): string
    {
        return $this->value;
    }

    /**
     * @param string $value
     */
    public function setValue(string $value): void
    {
        $this->value = $value;
    }


}

And this is my messenger.yaml:这是我的信使。yaml:

framework:
    messenger:

        transports:
            vincent.test.rabbitMq: '%env(RABBITMQ_URL)%'

        routing:
            'App\TestRabbitMQ\TestMessage': vincent.test.rabbitMq

But when I publish a Message like this: $this->bus->dispatch(new TestMessage("testmessage123"));但是当我发布这样的消息时: $this->bus->dispatch(new TestMessage("testmessage123")); It will create a Queue named messages.它将创建一个名为消息的队列。 If I publish another Message with another name It will also go into this Queue.如果我用另一个名字发布另一个消息,它也会将 go 放入这个队列中。 What I want is a seperate Queue for every Message.我想要的是每条消息都有一个单独的队列。 在此处输入图像描述

I found the answer.我找到了答案。 You can just add the queue-name to the RABBITMQ_URL.您可以将队列名称添加到 RABBITMQ_URL。

URL = amqp://guest:guest@localhost:5672/"vhost"/"queuename" URL = amqp://guest:guest@localhost:5672/"vhost"/"queuename"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM