【发布时间】:2013-06-28 22:13:38
【问题描述】:
我相信这对于任何具有 MT/RMQ 基本知识的人来说都是一件容易的事。
我从网上获取了一个简单的客户端/服务器示例,我试图让它在我的机器上本地工作,但是我没有运气。我的 RabbitMQ 网络管理显示我的“客户端”消息正在发布,但是我的“服务器”没有接收这些消息。
这是我的代码:
// Server
class Program
{
static void Main(string[] args)
{
Console.WindowWidth = 200;
Console.WriteLine("This is the server");
Bus.Initialize(sbc =>
{
sbc.UseRabbitMq();
sbc.ReceiveFrom("rabbitmq://localhost/simple_first_server");
sbc.Subscribe(subs =>
{
subs.Handler<string>(msg => Console.WriteLine(msg));
});
});
Console.ReadKey();
}
}
// Client
class Program
{
static void Main(string[] args)
{
Console.WriteLine("This is the client");
Bus.Initialize(sbc =>
{
sbc.UseRabbitMq();
sbc.ReceiveFrom("rabbitmq://localhost/simple_first_server");
});
String read;
while (!String.IsNullOrEmpty(read = Console.ReadLine()))
{
Bus.Instance.Publish("hello");
}
Console.ReadKey();
}
}
作为参考,我运行的是 Windows 8(64 位)。除了安装 Erland 和 RabbitMQ 之外,我还没有配置 Windows - 也许我错过了安装步骤?
感谢您的帮助
【问题讨论】:
标签: .net rabbitmq masstransit