简体   繁体   English

无法让主题交换在 RabbitMQ AMQP 1.0 中工作

[英]Unable to get Topic Exchange to Work in RabbitMQ AMQP 1.0

I am finding it very difficult to work with RabbitMQ and AMQP 1.0, particularly as it pertains to topic exchanges using AMQPNetLite.我发现使用 RabbitMQ 和 AMQP 1.0 非常困难,特别是因为它与使用 AMQPNetLite 的主题交换有关。 I am unable to send a message using a topic exchange to a specific queue.我无法使用主题交换向特定队列发送消息。 I'm not even using wildcards.我什至没有使用通配符。

My situation is super simple too.我的情况也超级简单。 I have one topic exchange.我有一个主题交流。 I have one queue that the topic exchange sends to.我有一个主题交换发送到的队列。 When I send to the topic exchange, the queue never receives the message.当我发送到主题交换时,队列永远不会收到消息。

test.exchange:
  bind: testqueue - routing key: test

testqueue:
  bound to exchange with routing key: test

The AMQP 1.0 documentation says that the "Subject" is the routing key right? AMQP 1.0 文档说“主题”是路由键,对吗? Well when I use AMQPNetLite to send to RabbitMQ, it appears to connect, and the topic appears to have received the message, but it is never routed to the queue.好吧,当我使用 AMQPNetLite 发送到 RabbitMQ 时,它似乎已连接,并且主题似乎已收到消息,但从未路由到队列。

Here's the entire code:这是整个代码:

            var rabbitMqAddress = $"amqp://127.0.0.1:5672";
            var address = new Address(rabbitMqAddress);
            var producerName = $"Producer-test.topic-{Time.GetTimeStamp()}";

            var connection = new Connection(address, null, new Open
            {
                ContainerId = Guid.NewGuid().ToString(),
                ChannelMax = 64,
            }, null);

            var session = new Session(connection);
            var senderLink = new SenderLink(session, producerName, "/topic/test.exchange");

            senderLink.Send(new Message
            {
                BodySection = new AmqpValue { Value = "test 123" },
                Properties = new Properties
                {
                    Subject = "test",
                }
            });

在此处输入图片说明

The image proves the binding.图像证明了绑定。 Is there something I'm missing?有什么我想念的吗?

i think you mix to ways of doing it.我认为你混合了这样做的方式。 Either you publish to address "/topic/test" -where test is your routingkey OR you publish to "/exchange/test.exchange" and set the Subject-property to "test".您要么发布到地址“/topic/test”-其中 test 是您的路由密钥,要么发布到“/exchange/test.exchange”并将主题属性设置为“test”。

Both works.两者都有效。 if you you the "/topic/"-prefix in your address you are going through the default "amq.topic"-exchange and not your own "test-exchange".如果您在地址中使用“/topic/”-前缀,则您将通过默认的“amq.topic”-exchange 而不是您自己的“test-exchange”。

made sense?有道理? more information in the "Routing and Addressing"-secion here: https://github.com/rabbitmq/rabbitmq-amqp1.0此处“路由和寻址”部分中的更多信息: https : //github.com/rabbitmq/rabbitmq-amqp1.0

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

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