-
-
Save tugberkugurlu/4485630 to your computer and use it in GitHub Desktop.
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
[Test] | |
public void Should_be_able_to_consume() | |
{ | |
var autoResetEvent = new AutoResetEvent(false); | |
using (var channel = connection.OpenChannel()) | |
{ | |
channel.Declare(queue); | |
var settings = new ConsumerSettings(queue) | |
{ | |
ConsumerTag = Guid.NewGuid().ToString() | |
}; | |
var loop = new QueueingConsumerLoop(); | |
var handlerSelector = new BasicHandlerSelector(); | |
handlerSelector.SetHandler(message => | |
{ | |
var stringMessage = Encoding.UTF8.GetString(message.Body); | |
Console.Out.WriteLine("Got Message: '{0}'", stringMessage); | |
autoResetEvent.Set(); | |
}); | |
var executionPolicyBuilder = new DefaultExecutionPolicyBuilder(); | |
var consumer = new Consumer( | |
loop, | |
handlerSelector, | |
executionPolicyBuilder | |
); | |
channel.StartConsuming(consumer, settings); | |
autoResetEvent.WaitOne(TimeSpan.FromSeconds(10)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment