无法使主题交换在 RabbitMQ AMQP 1.0 中工作
Unable to get Topic Exchange to Work in RabbitMQ AMQP 1.0
我发现使用 RabbitMQ 和 AMQP 1.0 非常困难,特别是因为它涉及使用 AMQPNetLite 的主题交换。我无法使用主题交换将消息发送到特定队列。我什至没有使用通配符。
我的情况也超级简单。我有一个主题交换。我有一个主题交换发送到的队列。当我发送到主题交换器时,队列从未收到消息。
test.exchange:
bind: testqueue - routing key: test
testqueue:
bound to exchange with routing key: test
AMQP 1.0 文档说“Subject”是路由键,对吗?好吧,当我使用 AMQPNetLite 发送到 RabbitMQ 时,它似乎已连接,主题似乎已收到消息,但从未路由到队列。
完整代码如下:
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",
}
});
图片为绑定证明。有什么我想念的吗?
我认为你混合了两种方法。
要么你发布到地址“/topic/test” - 其中 test 是你的 routingkey
要么
您发布到“/exchange/test.exchange”并将 Subject-属性 设置为“test”。
两者都有效。如果您在地址中使用“/topic/”前缀,您将通过默认的“amq.topic”-exchange 而不是您自己的“test-exchange”。
有道理吗?
更多信息在“路由和寻址”部分:https://github.com/rabbitmq/rabbitmq-amqp1.0
我发现使用 RabbitMQ 和 AMQP 1.0 非常困难,特别是因为它涉及使用 AMQPNetLite 的主题交换。我无法使用主题交换将消息发送到特定队列。我什至没有使用通配符。
我的情况也超级简单。我有一个主题交换。我有一个主题交换发送到的队列。当我发送到主题交换器时,队列从未收到消息。
test.exchange:
bind: testqueue - routing key: test
testqueue:
bound to exchange with routing key: test
AMQP 1.0 文档说“Subject”是路由键,对吗?好吧,当我使用 AMQPNetLite 发送到 RabbitMQ 时,它似乎已连接,主题似乎已收到消息,但从未路由到队列。
完整代码如下:
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",
}
});
图片为绑定证明。有什么我想念的吗?
我认为你混合了两种方法。 要么你发布到地址“/topic/test” - 其中 test 是你的 routingkey 要么 您发布到“/exchange/test.exchange”并将 Subject-属性 设置为“test”。
两者都有效。如果您在地址中使用“/topic/”前缀,您将通过默认的“amq.topic”-exchange 而不是您自己的“test-exchange”。
有道理吗? 更多信息在“路由和寻址”部分:https://github.com/rabbitmq/rabbitmq-amqp1.0