EasyNetQ 是 RabbitMQ 的 .NET 開發包。

EasyNetQ 是 RabbitMQ 的 .NET 開發包。git

示例代碼:github

var bus = RabbitHutch.CreateRabbitBus("localhost");
var message = new MyMessage {Text = "Hello!"};
bus.Publish(message);

 

GIT庫:.net

https://github.com/EasyNetQ/EasyNetQcode

 

 

Goals:server

  1. To make working with RabbitMQ on .NET as easy as possible.

To connect to a RabbitMQ broker...rabbitmq

var bus = RabbitHutch.CreateBus("host=localhost");

To publish a message...ip

bus.Publish(message);

To subscribe to a message...開發

bus.Subscribe<MyMessage>("my_subscription_id", msg => Console.WriteLine(msg.Text));

Remote procedure call...get

var request = new TestRequestMessage {Text = "Hello from the client! "};
bus.Request<TestRequestMessage, TestResponseMessage>(request, response => 
    Console.WriteLine("Got response: '{0}'", response.Text));

RPC server...it

bus.Respond<TestRequestMessage, TestResponseMessage>(request => 
    new TestResponseMessage{ Text = request.Text + " all done!" });
相關文章
相關標籤/搜索