Created
January 20, 2015 17:53
-
-
Save micdenny/02763d6852b40b1b60ee to your computer and use it in GitHub Desktop.
Rpc does not work anymore with version 0.40.3.351
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using EasyNetQ; | |
namespace ConsoleApplication5 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var resetEvent = new ManualResetEventSlim(); | |
var consumer = new Thread(() => | |
{ | |
var bus = RabbitHutch.CreateBus("host=localhost"); | |
//bus.RespondAsync<MyRequest, MyResponse>(async request => | |
//{ | |
// await Task.Yield(); | |
// return new MyResponse(); | |
//}); | |
bus.Respond<MyRequest, MyResponse>(request => | |
{ | |
return new MyResponse(); | |
}); | |
resetEvent.Wait(); | |
bus.Dispose(); | |
}); | |
var publisher = new Thread(() => | |
{ | |
var bus = RabbitHutch.CreateBus("host=localhost"); | |
while (!resetEvent.IsSet) | |
{ | |
//var result = bus.RequestAsync<MyRequest, MyResponse>(new MyRequest()).Result; | |
var result = bus.Request<MyRequest, MyResponse>(new MyRequest()); | |
Console.WriteLine(result.GetHashCode()); | |
if (!resetEvent.IsSet) Thread.Sleep(1000); | |
} | |
bus.Dispose(); | |
}); | |
consumer.Start(); | |
publisher.Start(); | |
Console.WriteLine("Press enter to close the application..."); | |
Console.ReadLine(); | |
resetEvent.Set(); | |
} | |
} | |
public class MyRequest | |
{ | |
} | |
public class MyResponse | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment