Skip to content

Instantly share code, notes, and snippets.

@micdenny
Created January 20, 2015 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save micdenny/02763d6852b40b1b60ee to your computer and use it in GitHub Desktop.
Save micdenny/02763d6852b40b1b60ee to your computer and use it in GitHub Desktop.
Rpc does not work anymore with version 0.40.3.351
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