Beispiel #1
0
        async Task AsyncOnStart()
        {
            try
            {
                var defaultFactory = LogManager.Use <DefaultFactory>();
                defaultFactory.Level(LogLevel.Info);

                iocContainer = new Container(new IocContainer())
                {
                    Name = "Root Container"
                };

                var endpointConfiguration = SharedEndpointConfiguration.CreateEndpointConfiguration(EndPointName, routing => routing.RegisterPublisher(typeof(BusinessProcessScheduled), EndPointName));

                endpointConfiguration.UseContainer <StructureMapBuilder>(b => b.ExistingContainer(iocContainer));

                endpointConfiguration.UsePersistence <NHibernatePersistence>().ConnectionString(SharedEndpointConfiguration.NsbSqlConnection);

                endpointConfiguration.EnableInstallers();

                endpoint = await Endpoint.Start(endpointConfiguration).ConfigureAwait(false);

                PerformStartupOperations();
            }
            catch (Exception exception)
            {
                Logger.Fatal("Failed to start", exception);
                Environment.FailFast("Failed to start", exception);
            }
        }
        private static async Task MakeItSo()
        {
            var endpointConfiguration = SharedEndpointConfiguration.CreateEndpointConfiguration("Case00026950.Test");

            endpointConfiguration.UsePersistence <InMemoryPersistence>();

            endpointConfiguration.SendOnly();

            var bus = await Endpoint.Start(endpointConfiguration).ConfigureAwait(false);

            var transactionId = Guid.NewGuid();

            Console.Write("Hit any key to send");
            Console.ReadKey();

            await bus.Send(new StartSomeBusinessProcess
            {
                TransactionId = transactionId
            }).ConfigureAwait(false);

            Console.WriteLine($"Sent StartSomeBusinessProcess for transaction = {transactionId}");

            await bus.Stop().ConfigureAwait(false);
        }