private static void TestTopology(Link link) { ColorConsole.WriteLine("Creating topology configurators"); link.CreatePersistentTopologyConfigurator(PersConfigure, configurationError: PersOnException); ColorConsole.WriteLine("Starting..."); link.Initialize(); ColorConsole.WriteLine("Configuring topology"); try { link.ConfigureTopologyAsync(OnceConfigure, TimeSpan.FromSeconds(10)) .WaitAndUnwrapException(); ColorConsole.WriteLine("Topology configured"); } catch (Exception ex) { ColorConsole.WriteLine($"Topology config exception: {ex}"); } }
private static void TestPublish(Link link) { ColorConsole.WriteLine("Starting..."); link.Initialize(); using ( var producer = link.CreateProducer( async cfg => await cfg.ExchangeDeclare("link.consume", LinkExchangeType.Fanout), config: cfg => cfg.TypeNameMap(map => map.Set<string>("string").Set<MyClass>("woot"))) ) { ColorConsole.WriteLine("Publish"); var sw = Stopwatch.StartNew(); var tasks = Enumerable .Range(0, 100) .Select(i => $"Item {i + 1}") .Select(body => producer.PublishAsync( body, new LinkMessageProperties {DeliveryMode = LinkMessageDeliveryMode.Persistent}, new LinkPublishProperties {Mandatory = false} )) .ToArray(); ColorConsole.WriteLine("Waiting for publish end..."); Task.WaitAll(tasks); ColorConsole.WriteLine("Publish done"); sw.Stop(); Console.WriteLine("Done in {0:0.###}s", sw.Elapsed.TotalSeconds); } }