public async Task CreateAndBindQueueAsync() { var options = new RabbitOptions(); options.FactoryOptions.Uri = new Uri("amqp://*****:*****@localhost:5672/"); var top = new Topologer(options); var error = await top.CreateExchangeAsync("TestExchangeTest", "direct", false, false, null).ConfigureAwait(false); Assert.False(error); error = await top.CreateQueueAsync("TestQueueTest", false, false, false, null).ConfigureAwait(false); Assert.False(error); error = await top.BindQueueToExchangeAsync("TestQueueTest", "TestExchangeTest", "TestRoutingKeyTest", null).ConfigureAwait(false); Assert.False(error); error = await top.DeleteExchangeAsync("TestExchangeTest").ConfigureAwait(false); Assert.False(error); error = await top.DeleteQueueAsync("TestQueueTest").ConfigureAwait(false); Assert.False(error); }
public async Task AutoPublishAndConsume() { await autoPublisher.StartAsync().ConfigureAwait(false); const ulong count = 10000; var processReceiptsTask = ProcessReceiptsAsync(autoPublisher, count); var publishLettersTask = PublishLettersAsync(autoPublisher, count); var consumeMessagesTask = ConsumeMessagesAsync(consumer, count); while (!publishLettersTask.IsCompleted) { await Task.Delay(1).ConfigureAwait(false); } while (!processReceiptsTask.IsCompleted) { await Task.Delay(1).ConfigureAwait(false); } await autoPublisher.StopAsync().ConfigureAwait(false); while (!consumeMessagesTask.IsCompleted) { await Task.Delay(1).ConfigureAwait(false); } Assert.True(publishLettersTask.IsCompletedSuccessfully); Assert.True(processReceiptsTask.IsCompletedSuccessfully); Assert.True(consumeMessagesTask.IsCompletedSuccessfully); Assert.False(processReceiptsTask.Result); Assert.False(consumeMessagesTask.Result); await topologer.DeleteQueueAsync("TestAutoPublisherConsumerQueue").ConfigureAwait(false); }
private static async Task SetupAsync() { var sw = Stopwatch.StartNew(); config = await ConfigReader.ConfigFileReadAsync("Config.json"); channelPool = new ChannelPool(config); topologer = new Topologer(channelPool); apub1 = new Publisher(channelPool, new byte[] { }); apub2 = new Publisher(channelPool, new byte[] { }); apub3 = new Publisher(channelPool, new byte[] { }); apub4 = new Publisher(channelPool, new byte[] { }); await Console.Out.WriteLineAsync("- Creating stress test queues!").ConfigureAwait(false); foreach (var kvp in config.ConsumerSettings) { await topologer .DeleteQueueAsync(kvp.Value.QueueName) .ConfigureAwait(false); } foreach (var kvp in config.ConsumerSettings) { await topologer .CreateQueueAsync(kvp.Value.QueueName, true) .ConfigureAwait(false); } await apub1.StartAutoPublishAsync().ConfigureAwait(false); await apub2.StartAutoPublishAsync().ConfigureAwait(false); await apub3.StartAutoPublishAsync().ConfigureAwait(false); await apub4.StartAutoPublishAsync().ConfigureAwait(false); con1 = new Consumer(channelPool, "Consumer1"); con2 = new Consumer(channelPool, "Consumer2"); con3 = new Consumer(channelPool, "Consumer3"); con4 = new Consumer(channelPool, "Consumer4"); sw.Stop(); await Console .Out .WriteLineAsync($"- Setup has finished in {sw.ElapsedMilliseconds} ms.") .ConfigureAwait(false); }
public async Task CreateAndDeleteQueueAsync() { var config = new Config(); config.FactorySettings.Uri = new Uri("amqp://*****:*****@localhost:5672/"); var top = new Topologer(config); var error = await top.CreateQueueAsync("TestQueueTest", false, false, false, null).ConfigureAwait(false); Assert.False(error); error = await top.DeleteQueueAsync("TestQueueTest", false, false).ConfigureAwait(false); Assert.False(error); }
public async Task CreateAndDeleteQueueAsync() { var options = new Options(); options.FactoryOptions.Uri = new Uri("amqp://*****:*****@localhost:5672/"); var top = new Topologer(options); var error = await top.CreateQueueAsync("TestQueueTest", false, false, false, null).ConfigureAwait(false); Assert.False(error); error = await top.DeleteQueueAsync("TestQueueTest", false, false).ConfigureAwait(false); Assert.False(error); }
private static async Task SetupAsync() { var sw = Stopwatch.StartNew(); options = await JsonFileReader.ReadFileAsync <Options>("Config.json"); channelPool = new ChannelPool(options); topologer = new Topologer(channelPool); apub1 = new Publisher( channelPool, _serializationProvider, _encryptionProvider, _compressionProvider); apub2 = new Publisher( channelPool, _serializationProvider, _encryptionProvider, _compressionProvider); apub3 = new Publisher( channelPool, _serializationProvider, _encryptionProvider, _compressionProvider); apub4 = new Publisher( channelPool, _serializationProvider, _encryptionProvider, _compressionProvider); await Console.Out.WriteLineAsync("- Creating stress test queues!").ConfigureAwait(false); foreach (var kvp in options.ConsumerOptions) { await topologer .DeleteQueueAsync(kvp.Value.QueueName) .ConfigureAwait(false); } foreach (var kvp in options.ConsumerOptions) { await topologer .CreateQueueAsync(kvp.Value.QueueName, true) .ConfigureAwait(false); } await apub1.StartAutoPublishAsync().ConfigureAwait(false); await apub2.StartAutoPublishAsync().ConfigureAwait(false); await apub3.StartAutoPublishAsync().ConfigureAwait(false); await apub4.StartAutoPublishAsync().ConfigureAwait(false); con1 = new Consumer(channelPool, "Consumer1"); con2 = new Consumer(channelPool, "Consumer2"); con3 = new Consumer(channelPool, "Consumer3"); con4 = new Consumer(channelPool, "Consumer4"); sw.Stop(); await Console .Out .WriteLineAsync($"- Setup has finished in {sw.ElapsedMilliseconds} ms.") .ConfigureAwait(false); }