コード例 #1
0
        public async Task TheStartupTimeShouldBeAcceptable()
        {
            const int numMessageTypes = 50;

            var assemblyBuilder = EmitMessageContractsAndHandlersAssembly(numMessageTypes);

            var logger = TestHarnessLoggerFactory.Create(Guid.NewGuid(), GetType().FullName);
            var typeProvider = new AssemblyScanningTypeProvider(assemblyBuilder);

            var firstBus = new BusBuilder().Configure()
                                           .WithNames("MyTestSuite", Environment.MachineName)
                                           .WithDefaults(typeProvider)
                                           .WithTransport(new WindowsServiceBusTransportConfiguration()
                                                              .WithConnectionString(DefaultSettingsReader.Get<AzureServiceBusConnectionString>()))
                                           .WithLogger(logger)
                                           .WithDebugOptions(
                                               dc =>
                                                   dc.RemoveAllExistingNamespaceElementsOnStartup(
                                                       "I understand this will delete EVERYTHING in my namespace. I promise to only use this for test suites."))
                                           .Build();
            try
            {
                try
                {
                    await firstBus.Start(MessagePumpTypes.All);
                }
                catch (AggregateException exc)
                {
                    throw exc.Flatten();
                }
            }
            finally
            {
                firstBus.Dispose();
            }

            var subsequentBus = new BusBuilder().Configure()
                                                .WithNames("MyTestSuite", Environment.MachineName)
                                                .WithTransport(new WindowsServiceBusTransportConfiguration()
                                                                   .WithConnectionString(DefaultSettingsReader.Get<AzureServiceBusConnectionString>()))
                                                .WithDefaults(typeProvider)
                                                .WithLogger(logger)
                                                .Build();

            try
            {
                try
                {
                    await subsequentBus.Start(MessagePumpTypes.All);
                }
                catch (AggregateException exc)
                {
                    throw exc.Flatten();
                }
            }
            finally
            {
                subsequentBus.Dispose();
            }
        }
コード例 #2
0
        public async Task TheStartupTimeShouldBeAcceptable()
        {
            const int numMessageTypes = 100;

            var assemblyBuilder = EmitMessageContractsAndHandlersAssembly(numMessageTypes);

            var logger = new ConsoleLogger();
            var typeProvider = new AssemblyScanningTypeProvider(new[] {assemblyBuilder});

            var firstBus = new BusBuilder().Configure()
                                           .WithNames("MyTestSuite", Environment.MachineName)
                                           .WithConnectionString(CommonResources.ServiceBusConnectionString)
                                           .WithTypesFrom(typeProvider)
                                           .WithDefaultTimeout(TimeSpan.FromSeconds(10))
                                           .WithServerConnectionCount(100)
                                           .WithLogger(logger)
                                           .Build();
            try
            {
                using (new AssertingStopwatch("First bus startup", TimeSpan.FromMinutes(1)))
                {
                    {
                        try
                        {
                            await firstBus.Start(MessagePumpTypes.All);
                            WriteBlankLines();
                        }
                        catch (AggregateException exc)
                        {
                            throw exc.Flatten();
                        }
                    }
                }
            }
            finally
            {
                WriteBlankLines();
                firstBus.Dispose();
            }

            WriteBlankLines();

            var subsequentBus = new BusBuilder().Configure()
                                                .WithNames("MyTestSuite", Environment.MachineName)
                                                .WithConnectionString(CommonResources.ServiceBusConnectionString)
                                                .WithTypesFrom(typeProvider)
                                                .WithDefaultTimeout(TimeSpan.FromSeconds(10))
                                                .WithLogger(logger)
                                                .Build();

            try
            {
                using (new AssertingStopwatch("Subsequent bus startup", TimeSpan.FromSeconds(20)))
                {
                    try
                    {
                        await subsequentBus.Start(MessagePumpTypes.All);
                        WriteBlankLines();
                    }
                    catch (AggregateException exc)
                    {
                        throw exc.Flatten();
                    }
                }
            }
            finally
            {
                WriteBlankLines();
                subsequentBus.Dispose();
            }
        }