RabbitMQ C# 客户端不与 Apache Qpid Java Broker 对话
我已在 Windows 机器上安装了 Apache Qpid Java 代理的 M4 版本,并使用开箱即用的配置(通过 qpid-server.bat 脚本)启动它。
我现在尝试使用 RabbitMQ C# 客户端库(版本 1.5.3,为 .NET 3.0 编译)将消息发布到队列; 我的代码是:
public void PublishMessage(string message)
{
ConnectionFactory factory = new ConnectionFactory();
factory.Parameters.VirtualHost = "...";
IProtocol protocol = Protocols.FromEnvironment();
using (IConnection conn = factory.CreateConnection(protocol, "localhost", 5672))
{
using (IModel ch = conn.CreateModel())
{
string exchange = "...";
string routingKey = "...";
ch.BasicPublish(exchange, routingKey, null, Encoding.UTF8.GetBytes(message));
}
}
}
基本上,我不确定 factory.Parameters.VirtualHost
以及字符串 exchange
和 routingKey
使用什么值。 我尝试了各种组合,但似乎没有任何效果 - 我所得到的最接近的是在 Qpid 服务器日志中看到以下内容:
2009-03-19 17:11:04,248 WARN [pool-1-thread-1] queue.IncomingMessage (IncomingMessage.java:198) - MESSAGE DISCARDED: No routes for message - Message[(HC:896033 ID:1 Ref:1)]: 1; ref count: 1
看起来好像 Qpid 服务器正在接收消息,但不知道如何处理它。
任何关于我在客户端代码中需要什么配置值的建议(记住我在 virtualhosts.xml 中使用默认的 Qpid 配置)将不胜感激。 有关虚拟主机、交换器、队列和路由密钥以及 Qpid 如何将它们链接在一起的更多一般信息也将非常有用。
提前谢谢你,
艾伦
I've installed the M4 release of the Apache Qpid Java broker on a Windows box, and started it using the out-of-the-box configuration (via the qpid-server.bat script).
I'm now trying to publish a message to a queue using the RabbitMQ C# client library (version 1.5.3, compiled for .NET 3.0); my code is:
public void PublishMessage(string message)
{
ConnectionFactory factory = new ConnectionFactory();
factory.Parameters.VirtualHost = "...";
IProtocol protocol = Protocols.FromEnvironment();
using (IConnection conn = factory.CreateConnection(protocol, "localhost", 5672))
{
using (IModel ch = conn.CreateModel())
{
string exchange = "...";
string routingKey = "...";
ch.BasicPublish(exchange, routingKey, null, Encoding.UTF8.GetBytes(message));
}
}
}
Basically, I'm unsure what values to use for factory.Parameters.VirtualHost
and the strings exchange
and routingKey
. I've tried various combinations, but nothing seems to work - the closest I've got is seeing the following in the Qpid server log:
2009-03-19 17:11:04,248 WARN [pool-1-thread-1] queue.IncomingMessage (IncomingMessage.java:198) - MESSAGE DISCARDED: No routes for message - Message[(HC:896033 ID:1 Ref:1)]: 1; ref count: 1
which looks as though the Qpid server is receiving the message, but doesn't know what to do with it.
Any advice on what configuration values I need in my client code (bearing in mind I'm using the default Qpid config in virtualhosts.xml) would be much appreciated. More general information on virtual hosts, exchanges, queues and routing keys, and how Qpid links them all together, would also be very useful.
Thank you in advance,
Alan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅供参考,我最终成功了。 下面的代码向 localhost 虚拟主机上的 test.direct 交换中的队列 test-queue 发送一条消息(默认 Qpid 代理配置的所有部分):
Just for reference, I managed to get this working in the end. The code below sends a message to the queue test-queue in the test.direct exchange on the localhost virtual host (all part of the default Qpid broker configuration):