Ejemplo n.º 1
0
        public static async Task Main(string[] args)
        {
            // Create the LiteDb database so we can work with some default movies.
            Database.Setup();

            var host = Host.CreateDefaultBuilder(args);

            // Configure web-host.
            host.ConfigureWebHostDefaults(c => c.UseStartup <Startup>());

            // Configure NServiceBus
            host.UseNServiceBus(hostBuilderContext =>
            {
                var endpointConfiguration = new EndpointConfiguration("EventualConsistencyDemo");
                endpointConfiguration.ApplyCommonConfiguration(routingConfig =>
                {
                    routingConfig.RouteToEndpoint(typeof(Shared.Commands.SubmitOrder), "server");
                });

                return(endpointConfiguration);
            });


            await host.Build().RunAsync();
        }
Ejemplo n.º 2
0
    public static async Task AsyncMain(CancellationToken cancellationToken)
    {
        Console.Title = "Samples.Store.CustomerRelations";
        var endpointConfiguration = new EndpointConfiguration("Store.CustomerRelations");

        endpointConfiguration.ApplyCommonConfiguration(
            transport =>
        {
            var routing = transport.Routing();
            routing.RegisterPublisher(typeof(ClientBecamePreferred).Assembly, "Store.Messages.Events", "Store.Sales");
            routing.RegisterPublisher(typeof(ClientBecamePreferred), "Store.CustomerRelations");
        });


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

        while (!cancellationToken.IsCancellationRequested)
        {
            await Task.Delay(3000, cancellationToken)
            .ConfigureAwait(false);
        }

        await endpointInstance.Stop()
        .ConfigureAwait(false);
    }
Ejemplo n.º 3
0
    static async Task Main()
    {
        Console.Title = "UnreliableServiceEndpoint";
        var endpointConfiguration = new EndpointConfiguration("UnreliableServiceEndpoint");

        endpointConfiguration.ApplyCommonConfiguration().RegisterRoutes();

        endpointConfiguration.Recoverability()
        .Immediate(retries => retries.NumberOfRetries(1))
        .Delayed(delayed =>
                 delayed.NumberOfRetries(0)); //allows you to see error queue operation with ServicePulse

        var client = new HttpClient
        {
            BaseAddress = new Uri(ServerInfo.UnreliableServiceBaseAddress),
            Timeout     = TimeSpan.FromSeconds(5)
        };

        endpointConfiguration.RegisterComponents(c => c.RegisterSingleton(client));

        endpointConfiguration.ReportCustomChecksTo("Particular.ServiceControl");

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

        Console.WriteLine("Press any key to exit");
        Console.ReadKey();
        await endpointInstance.Stop()
        .ConfigureAwait(false);
    }
        static async Task Main(string[] args)
        {
            var serviceName = typeof(Program).Namespace;

            Console.Title = serviceName;

            var config = new EndpointConfiguration(serviceName);

            config.ApplyCommonConfiguration();
            config.ReportCustomChecksTo(serviceControlQueue: "Particular.ServiceControl");
            var recoverabilityConfig = config.Recoverability();

            recoverabilityConfig.Immediate(immediate =>
            {
                immediate.NumberOfRetries(1);
            });
            recoverabilityConfig.Delayed(delayed =>
            {
                delayed.NumberOfRetries(1);
                delayed.TimeIncrease(TimeSpan.FromSeconds(5));
            });

            var endpointInstance = await Endpoint.Start(config);

            Console.WriteLine($"{serviceName} sarted. Press any key to stop.");
            Console.ReadLine();

            await endpointInstance.Stop();
        }
Ejemplo n.º 5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddSignalR();
            var builder = new ContainerBuilder();

            builder.Populate(services);

            builder.Register(c => endpoint)
            .As <IEndpointInstance>()
            .SingleInstance();

            var container = builder.Build();

            var endpointConfiguration = new EndpointConfiguration("Store.ECommerce");

            endpointConfiguration.PurgeOnStartup(true);
            endpointConfiguration.ApplyCommonConfiguration(transport =>
            {
                var routing = transport.Routing();
                routing.RouteToEndpoint(typeof(Store.Messages.Commands.SubmitOrder).Assembly, "Store.Messages.Commands", "Store.Sales");
            });
            endpointConfiguration.UseContainer <AutofacBuilder>(
                customizations: customizations =>
            {
                customizations.ExistingLifetimeScope(container);
            });

            endpoint = Endpoint.Start(endpointConfiguration).GetAwaiter().GetResult();

            return(new AutofacServiceProvider(container));
        }
Ejemplo n.º 6
0
        public static IHostBuilder CreateWebHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .UseNServiceBus(ctx =>
        {
            var config = new EndpointConfiguration("Webapp");
            config.ApplyCommonConfiguration();

            return(config);
        })
        .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup <Startup>(); });
Ejemplo n.º 7
0
    static async Task AsyncStart()
    {
        var endpointConfiguration = new EndpointConfiguration("Store.ECommerce");
        endpointConfiguration.PurgeOnStartup(true);
        endpointConfiguration.ApplyCommonConfiguration();

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

        AreaRegistration.RegisterAllAreas();
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
    }
Ejemplo n.º 8
0
    static async Task Main()
    {
        Console.Title = "ValidationEndpoint";
        var endpointConfiguration = new EndpointConfiguration("ValidationEndpoint");
        endpointConfiguration.ApplyCommonConfiguration();

        var endpointInstance = await Endpoint.Start(endpointConfiguration)
            .ConfigureAwait(false);
        Console.WriteLine("Press any key to exit");
        Console.ReadKey();
        await endpointInstance.Stop()
            .ConfigureAwait(false);
    }
Ejemplo n.º 9
0
        public void Configuration(IAppBuilder appBuilder)
        {
            var bootstrapper = new WindsorBootstrapper(AppDomain.CurrentDomain.BaseDirectory, filter: "Marketing*.*");
            var container    = bootstrapper.Boot();

            var store = CommonConfiguration.CreateEmbeddableDocumentStore("Marketing", session =>
            {
                SeedData.Products().ForEach(s => session.Store(s));
                session.Store(SeedData.HomeStructure());
            });

            container.Register(Component.For <IDocumentStore>().Instance(store).LifestyleSingleton());

            var endpointConfiguration = new EndpointConfiguration("Marketing");

            endpointConfiguration.UseContainer <WindsorBuilder>(c => c.ExistingContainer(container));

            endpointConfiguration.ApplyCommonConfiguration();
            endpointConfiguration.UseRavenPersistence(store);
            endpointConfiguration.LimitMessageProcessingConcurrencyTo(1);

            //var timeoutManager = endpointConfiguration.TimeoutManager();
            //timeoutManager.LimitMessageProcessingConcurrencyTo(4);

            var endpoint = Endpoint.Start(endpointConfiguration).GetAwaiter().GetResult();

            container.Register(Component.For <IMessageSession>().Instance(endpoint));

            var config = new HttpConfiguration();

            config.Formatters.Clear();
            config.Formatters.Add(new JsonMediaTypeFormatter());

            config.DependencyResolver = new WindsorDependencyResolver(container);

            config.Formatters
            .JsonFormatter
            .SerializerSettings
            .ContractResolver = new CamelCasePropertyNamesContractResolver();

            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            appBuilder.UseCors(CorsOptions.AllowAll);
            appBuilder.UseWebApi(config);
        }
Ejemplo n.º 10
0
    static async Task AsyncStart()
    {
        EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Store.ECommerce");
        endpointConfiguration.PurgeOnStartup(true);

        endpointConfiguration.ApplyCommonConfiguration();
        endpointConfiguration.SendFailedMessagesTo("error");

        Endpoint = await NServiceBus.Endpoint.Start(endpointConfiguration);

        AreaRegistration.RegisterAllAreas();
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
    }
Ejemplo n.º 11
0
    static async Task AsyncStart()
    {
        var endpointConfiguration = new EndpointConfiguration("Store.ECommerce");

        endpointConfiguration.PurgeOnStartup(true);
        endpointConfiguration.ApplyCommonConfiguration();

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

        AreaRegistration.RegisterAllAreas();
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
    }
Ejemplo n.º 12
0
    static async Task AsyncMain()
    {
        Console.Title = "Samples.Store.CustomerRelations";
        var endpointConfiguration = new EndpointConfiguration("Store.CustomerRelations");

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

        Console.WriteLine("Press any key to exit");
        Console.ReadKey();
        await endpointInstance.Stop()
        .ConfigureAwait(false);
    }
        public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .ConfigureLogging((hostingContext, loggingBuilder) =>
        {
            loggingBuilder.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
        })
        .UseNServiceBus(ctx =>
        {
            var endpointConfiguration = new EndpointConfiguration("WebApp");
            endpointConfiguration.ApplyCommonConfiguration();

            return(endpointConfiguration);
        })
        .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup <Startup>(); });
Ejemplo n.º 14
0
    static async Task Main()
    {
        Console.Title = "BatchDataItemProcessingEndpoint";
        var endpointConfiguration = new EndpointConfiguration("BatchDataItemProcessingEndpoint");

        endpointConfiguration.ApplyCommonConfiguration().RegisterRoutes();

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

        Console.WriteLine("Press any key to exit");
        Console.ReadKey();
        await endpointInstance.Stop()
        .ConfigureAwait(false);
    }
Ejemplo n.º 15
0
        public static IHostBuilder BuildWebHost(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(c => c.UseStartup <Startup>())
        .UseNServiceBus(c =>
        {
            var endpointConfiguration = new EndpointConfiguration("Store.ECommerce");
            endpointConfiguration.PurgeOnStartup(true);
            endpointConfiguration.ApplyCommonConfiguration(transport =>
            {
                var routing = transport.Routing();
                routing.RouteToEndpoint(typeof(Messages.Commands.SubmitOrder).Assembly, "Store.Messages.Commands", "Store.Sales");
            });

            return(endpointConfiguration);
        });
Ejemplo n.º 16
0
    static async Task AsyncStart()
    {
        EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Store.ECommerce");

        endpointConfiguration.PurgeOnStartup(true);

        endpointConfiguration.ApplyCommonConfiguration();
        endpointConfiguration.SendFailedMessagesTo("error");

        Endpoint = await NServiceBus.Endpoint.Start(endpointConfiguration);

        AreaRegistration.RegisterAllAreas();
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
    }
Ejemplo n.º 17
0
 static async Task AsyncMain()
 {
     Console.Title = "Samples.Store.CustomerRelations";
     EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Store.CustomerRelations");
     endpointConfiguration.ApplyCommonConfiguration();
     endpointConfiguration.SendFailedMessagesTo("error");
     IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration);
     try
     {
         Console.WriteLine("Press any key to exit");
         Console.ReadKey();
     }
     finally
     {
         await endpoint.Stop();
     }
 }
Ejemplo n.º 18
0
    public static async Task AsyncMain(CancellationToken cancellationToken)
    {
        Console.Title = "Samples.Store.Operations";
        var endpointConfiguration = new EndpointConfiguration("Store.Operations");

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

        while (!cancellationToken.IsCancellationRequested)
        {
            await Task.Delay(3000, cancellationToken)
            .ConfigureAwait(false);
        }

        await endpointInstance.Stop()
        .ConfigureAwait(false);
    }
Ejemplo n.º 19
0
    static async Task AsyncMain()
    {
        EndpointConfiguration endpointConfiguration = new EndpointConfiguration();
        endpointConfiguration.EndpointName("Store.ContentManagement");
        endpointConfiguration.ApplyCommonConfiguration();
        endpointConfiguration.SendFailedMessagesTo("error");

        IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration);
        try
        {
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
        finally
        {
            await endpoint.Stop();
        }
    }
Ejemplo n.º 20
0
    static async Task AsyncMain()
    {
        Console.Title = "Samples.Store.ContentManagement";
        var endpointConfiguration = new EndpointConfiguration("Store.ContentManagement");

        endpointConfiguration.ApplyCommonConfiguration(transport =>
        {
            var routing = transport.Routing();
            routing.RouteToEndpoint(typeof(Store.Messages.RequestResponse.ProvisionDownloadRequest), "Store.Operations");
        });

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

        Console.WriteLine("Press any key to exit");
        Console.ReadKey();
        await endpointInstance.Stop()
        .ConfigureAwait(false);
    }
Ejemplo n.º 21
0
    static async Task AsyncMain()
    {
        Console.Title = "Samples.Store.Operations";
        EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Store.Operations");

        endpointConfiguration.ApplyCommonConfiguration();
        endpointConfiguration.SendFailedMessagesTo("error");
        IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration);

        try
        {
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
        finally
        {
            await endpoint.Stop();
        }
    }
Ejemplo n.º 22
0
    static async Task AsyncMain()
    {
        Console.Title = "Samples.Store.Sales";
        var endpointConfiguration = new EndpointConfiguration("Store.Sales");
        endpointConfiguration.ApplyCommonConfiguration();

        var endpointInstance = await Endpoint.Start(endpointConfiguration)
            .ConfigureAwait(false);
        try
        {
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
        finally
        {
            await endpointInstance.Stop()
                .ConfigureAwait(false);
        }
    }
    static async Task AsyncMain()
    {
        EndpointConfiguration endpointConfiguration = new EndpointConfiguration();

        endpointConfiguration.EndpointName("Store.ContentManagement");
        endpointConfiguration.ApplyCommonConfiguration();
        endpointConfiguration.SendFailedMessagesTo("error");

        IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration);

        try
        {
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
        finally
        {
            await endpoint.Stop();
        }
    }
Ejemplo n.º 24
0
        static async Task MainAsync()
        {
            Console.Title = "EndpointB - Finance";

            var endpointConfiguration = new EndpointConfiguration("Finance");

            endpointConfiguration.ApplyCommonConfiguration();

            // Routing
            var transport = endpointConfiguration.UseTransport <LearningTransport>();

            transport.Routing().RouteToEndpoint(typeof(CreateInvoiceProposals).Assembly, "InvoiceProcessing");
            transport.Routing().RouteToEndpoint(typeof(CreateInvoice).Assembly, "Finance");

            var endpoint = await Endpoint.Start(endpointConfiguration);

            Console.WriteLine("Press a key to quit...");
            Console.ReadKey();

            await endpoint.Stop();
        }
Ejemplo n.º 25
0
        static async Task Main(string[] args)
        {
            var serviceName = typeof(Program).Namespace;

            Console.Title = serviceName;

            var config = new EndpointConfiguration(serviceName);

            config.ApplyCommonConfiguration(configureRouting: routing =>
            {
                routing.RouteToEndpoint(typeof(AuthorizeCard), "Finance.PaymentGateway");
                routing.RouteToEndpoint(typeof(ReleaseCardAuthorization), "Finance.PaymentGateway");
                routing.RouteToEndpoint(typeof(ChargeCard), "Finance.PaymentGateway");
            });

            var endpointInstance = await Endpoint.Start(config);

            Console.WriteLine($"{serviceName} started. Press any key to stop.");
            Console.ReadLine();

            await endpointInstance.Stop();
        }