// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); var connectionString = Configuration["ServiceBusConnectionString"]; factory = new RequestResponseFactory(connectionString, "thequeue", "theotherqueue"); factory.EnsureEntitiesExist().GetAwaiter().GetResult(); services.AddSingleton(factory); services.AddLogging(builder => { builder.AddConsole(); }); }
static void Main(string[] args) { Console.WriteLine("Service Bus Test Tool"); Console.WriteLine("============================="); if (!Config.ParseArgs(args, Console.Out)) { return; } logger = new ConsoleLogger(Console.Out); logger.Start(); Console.CancelKeyPress += Console_CancelKeyPress; try { var factory = new RequestResponseFactory(Config.ConnectionString, Config.QueueSendName, Config.QueueRespondName); factory.EnsureEntitiesExist().GetAwaiter().GetResult(); if (Config.SendRequest) { TimeOperation(() => SendRequests(factory)).GetAwaiter().GetResult(); } else if (Config.SendResponse) { RunConsumer(factory).GetAwaiter().GetResult(); } else { throw new Exception("Fatal: Unrecognized action initiated"); } } catch (Exception ex) { var origColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message); Console.ForegroundColor = origColor; } }