Esempio n. 1
0
        public static async Task MainAsync()
        {
            // This is how you tell Cumulus where to find all your message types and handlers.
            var typeProvider = new AssemblyScanningTypeProvider(Assembly.GetExecutingAssembly(), typeof (NewOrderRecieved).Assembly, typeof (OrderPizzaCommand).Assembly);

            var connectionString = ConfigurationManager.AppSettings["AzureConnectionString"];

            var bus = new BusBuilder().Configure()
                                      .WithNames("Ordering", Environment.MachineName)
                                      .WithConnectionString(connectionString)
                                      .WithTypesFrom(typeProvider)
                                      .WithDefaultTimeout(TimeSpan.FromSeconds(10))
                                      .Build();
            await bus.Start(MessagePumpTypes.Response);

            while (true)
            {
                Console.WriteLine();
                Console.WriteLine("Press 1 to get the current wait time.");
                Console.WriteLine("Press 2 to order a pizza.");
                Console.WriteLine("Press 3 to Quit.");
                var input = Console.ReadLine();

                switch (input)
                {
                    case "1":

                        await HowLongDoesAPizzaTake(bus);
                        break;

                    case "2":
                        await OrderAPizza(bus);
                        break;

                    case "3":
                        await bus.Stop();
                        return;

                    default:
                        continue;
                }
            }
        }