EasyNetQ是RabbitMQ的.NET开发包。
示例代码:
varbus=RabbitHutch.CreateRabbitBus("localhost");varmessage=newMyMessage{Text="Hello!"};bus.Publish(message);目标:尽可能简化在.NET上使用RabbitMQ的工作。要连接到RabbitMQ代理...varbus=RabbitHutch.CreateBus("host=localhost");要发布消息...bus.Publish(message);订阅消息...bus.Subscribe<MyMessage>("my_subscription_id",msg=>Console.WriteLine(msg.Text));远程过程调用...varrequest=newTestRequestMessage{Text="Hellofromtheclient!"};bus.Request<TestRequestMessage,TestResponseMessage>(request,response=>Console.WriteLine("Gotresponse:'{0}'",response.Text));RPC服务器...bus.Respond<TestRequestMessage,TestResponseMessage>(request=>newTestResponseMessage{Text=request.Text+"alldone!"});
评论