【发布时间】:2021-11-01 17:24:33
【问题描述】:
我发现使用 RabbitMQ 和 AMQP 1.0 非常困难,特别是因为它与使用 AMQPNetLite 的主题交换有关。我无法使用主题交换向特定队列发送消息。我什至没有使用通配符。
我的情况也超级简单。我有一个话题交流。我有一个主题交换发送到的队列。当我发送到主题交换时,队列永远不会收到消息。
test.exchange:
bind: testqueue - routing key: test
testqueue:
bound to exchange with routing key: test
AMQP 1.0 文档说“主题”是路由键,对吗?好吧,当我使用 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",
}
});
图片证明了绑定。我有什么遗漏吗?
【问题讨论】:
标签: c# amqp amqpnetlite