static void Main(string[] args)
        {
            var eventStoreConfiguration = EventStoreSubscriptionConfiguration.FromAppConfig();

            EventStoreSubscriptionEndpoint eventStoreEndpoint = EventStoreSubscriptionEndpoint
                                                                .ListenTo(EventStoreUrl.Parse(eventStoreConfiguration.Url))
                                                                .WithCredentials(EventStoreUserCredentials.Parse(eventStoreConfiguration.UserCredentials.User, eventStoreConfiguration.UserCredentials.Password))
                                                                .WithEventTypeFromNameResolution(EventTypeFromNameResolver.FromTypesFromAssemblyContaining <AccountCredited>())
                                                                .WithInMemoryEventIndexStorage();

            MessagingFramework.Bootstrap()
            .ConfigureReceivingEndpoint(eventStoreEndpoint)
            .ConfigureMessageRouting()
            .Incoming.ForEvents
            .Handle <AccountCredited>().With <AccountCreditedHandler>()
            .Handle <AccountDebited>().With <AccountDebitedHandler>()
            .Handle <AccountOverdraftLimitReached>().With <AccountOverdraftLimitReachedHandler>()
            .Handle <AccountBalanceLimitReached>().With <AccountBalanceLimitReachedHandler>()
            .Initialise();

            MessageReceivingContext.MessageReceiver.StartReceiving((ex, message) => Console.WriteLine(ex.Message));
            MessageReceivingContext.Events.Subscribe("bankaccounts");

            Console.WriteLine("I am the subscriber. Press Enter to exit");
            Console.ReadLine();

            MessageReceivingContext.Events.Unsubscribe("bankaccounts");
            MessageReceivingContext.MessageReceiver.StopReceiving();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var eventStoreConfiguration = EventStoreSubscriptionConfiguration.FromAppConfig();

            EventStoreSubscriptionEndpoint eventStoreEndpoint = EventStoreSubscriptionEndpoint
                                                                .ListenTo(EventStoreUrl.Parse(eventStoreConfiguration.Url))
                                                                .WithCredentials(EventStoreUserCredentials.Parse(eventStoreConfiguration.UserCredentials.User, eventStoreConfiguration.UserCredentials.Password))
                                                                .WithEventTypeFromNameResolution(EventTypeFromNameResolver.FromTypesFromAssemblyContaining <PolicyBound>())
                                                                .WithSqlDatabaseEventIndexStorage();

            MessagingFramework.Bootstrap()
            .SetupDataConnectivity().WithSqlConnection()
            .SetupMessaging()
            .ConfigureReceivingEndpoint(eventStoreEndpoint)
            .ConfigureMessageRouting().Incoming.ForEvents.Handle <PolicyBound>().With <PolicyBoundHandler>()
            .Initialise();

            MessageReceivingContext.MessageReceiver.StartReceiving(OnError);
            MessageReceivingContext.Events.Subscribe(PolicyEventStreamId.Parse("EventIndexStorageExample"));

            Console.WriteLine("I Am SubscriberWithLocalEventIndexStorage");
            Console.ReadLine();

            MessageReceivingContext.MessageReceiver.StopReceiving();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var container = new IocContainer();

            container.RegisterInstance <IThirdPartyLibrary, ThirdPartyLibrary>();

            var eventStoreConfiguration = EventStoreSubscriptionConfiguration.FromAppConfig();

            EventStoreSubscriptionEndpoint eventStoreEndpoint = EventStoreSubscriptionEndpoint
                                                                .ListenTo(EventStoreUrl.Parse(eventStoreConfiguration.Url))
                                                                .WithCredentials(EventStoreUserCredentials.Parse(eventStoreConfiguration.UserCredentials.User, eventStoreConfiguration.UserCredentials.Password))
                                                                .WithEventTypeFromNameResolution(EventTypeFromNameResolver.FromTypesFromAssemblyContaining <PolicyBound>())
                                                                .WithInMemoryEventIndexStorage();

            MessagingFramework.Bootstrap()
            .ConfigureReceivingEndpoint(eventStoreEndpoint)
            .ConfigureMessageRouting().Incoming.ForEvents.Handle <PolicyBound>().With(container.Resolve <PolicyBoundHandler>())
            .Initialise();

            MessageReceivingContext.MessageReceiver.StartReceiving(OnError);
            MessageReceivingContext.Events.Subscribe(PolicyEventStreamId.Parse("ContainerExample"));

            Console.WriteLine("I Am Subscriber");
            Console.ReadLine();

            MessageReceivingContext.MessageReceiver.StopReceiving();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var eventStoreConfiguration = EventStoreSubscriptionConfiguration.FromAppConfig();

            EventStoreSubscriptionEndpoint eventStoreEndpoint = EventStoreSubscriptionEndpoint
                                                                .ListenTo(EventStoreUrl.Parse(eventStoreConfiguration.Url))
                                                                .WithCredentials(EventStoreUserCredentials.Parse(eventStoreConfiguration.UserCredentials.User, eventStoreConfiguration.UserCredentials.Password))
                                                                .WithEventTypeFromNameResolution(EventTypeFromNameResolver.FromTypesFromAssemblyContaining <PolicyBound>())
                                                                .WithInMemoryEventIndexStorage();

            MessagingFramework.Bootstrap()
            .ConfigureReceivingEndpoint(eventStoreEndpoint)
            .ConfigureMessageRouting()
            .Incoming.ForEvents
            .Handle <PolicyBound>().With(new PolicyBoundHandler())
            .Internal.ForCommands
            .Handle <AddPolicyHeader>().With <AddPolicyHeaderHandler>()
            .Handle <AddPolicyLines>().With <AddPolicyLinesHandler>()
            .Handle <AddActivity>().With <AddActivityHandler>()

            .Initialise();

            MessageReceivingContext.MessageReceiver.StartReceiving(OnError);
            MessageReceivingContext.Events.Subscribe(PolicyEventStreamId.Parse("Tenant1"));

            Console.WriteLine("I Am Subscriber");
            Console.ReadLine();

            MessageReceivingContext.MessageReceiver.StopReceiving();
        }
        static void Main()
        {
            HostFactory.Run(configurator =>
            {
                var container = new IocContainer(t => t.NameInCSharp());

                var eventSubscriptionConfig = EventStoreSubscriptionConfiguration.FromAppConfig();

                var eventStoreUrl = EventStoreUrl.Parse(eventSubscriptionConfig.Url);

                var eventStoreUserCredentials = EventStoreUserCredentials.Parse(
                    eventSubscriptionConfig.UserCredentials.User,
                    eventSubscriptionConfig.UserCredentials.Password);

                var eventTypeResolution = EventTypeFromNameResolver.FromTypesFromAssemblyContaining <NewRiskItemMapped>();

                var eventStoreEndpoint = EventStoreEndpoint
                                         .OnUrl(eventStoreUrl)
                                         .WithCredentials(eventStoreUserCredentials)
                                         .WithEventTypeFromNameResolution(eventTypeResolution);

                var eventStoreSubscriptionEndpoint = EventStoreSubscriptionEndpoint
                                                     .ListenTo(eventStoreUrl)
                                                     .WithCredentials(eventStoreUserCredentials)
                                                     .WithEventTypeFromNameResolution(eventTypeResolution)
                                                     .WithSqlDatabaseEventIndexStorage();

                Bootstrap.Application()
                .ResolveReferencesWith(container)
                .SetupDataConnectivity().WithSqlConnection()
                .SetupMessaging()
                .ConfigureSagas().WithDatabasePersistence()
                .ConfigureEventStoreEndpoint(eventStoreEndpoint)
                .ConfigureReceivingEndpoint(eventStoreSubscriptionEndpoint)
                .ConfigureMessageRouting().WireUpRouting()
                .Initialise();

                Trace.TraceInformation(
                    "Data warehouse service has started up and the types registered into the container are {0}{1}",
                    Environment.NewLine,
                    container.Describe());

                configurator.Service <DataWarehouseController>(s =>
                {
                    s.ConstructUsing(name => container.Resolve <DataWarehouseController>());
                    s.WhenStarted(c => c.Start());
                    s.WhenStopped(c => c.Stop());
                });

                configurator.RunAsLocalSystem();
                configurator.SetDescription("Applied Systems Data Warehouse Service");
                configurator.SetDisplayName("Applied Systems Data Warehouse Service");
                configurator.SetServiceName("Applied Systems Data Warehouse Service");
            });
        }
        static void Main()
        {
            var config             = RiskCaptureConfiguration.FromAppConfig();
            var eventStorageConfig = EventStoreMessageStorageConfiguration.FromAppConfig();

            var eventStoreEndpoint = EventStoreEndpoint
                                     .OnUrl(EventStoreUrl.Parse(eventStorageConfig.Url))
                                     .WithCredentials(
                EventStoreUserCredentials.Parse(
                    eventStorageConfig.UserCredentials.User,
                    eventStorageConfig.UserCredentials.Password))
                                     .WithEventTypeFromNameResolution(EventTypeFromNameResolver.FromTypesFromAssemblyContaining <NewRiskItemMapped>());

            HostFactory.Run(configurator =>
            {
                var container = new IocContainer(t => t.NameInCSharp());

                Bootstrap.Application()
                .ResolveReferencesWith(container)
                .ConfigureRiskCapture()
                .SetupMessaging()
                .ConfigureEventStoreEndpoint(eventStoreEndpoint)
                .ConfigureMessageRouting().WireUpRouting()
                .Initialise();

                Trace.TraceInformation(
                    "Risk Capture service has started up and the types registered into the container are {0}{1}",
                    Environment.NewLine,
                    container.Describe());

                configurator.Service <RiskCaptureController>(s =>
                {
                    s.ConstructUsing(name => new RiskCaptureController(config.Url, container.Resolve <IMessageReceiver>()));
                    s.WhenStarted(c => c.Start());
                    s.WhenStopped(c => c.Stop());
                });

                configurator.RunAsLocalSystem();
                configurator.SetDescription("Applied Systems Risk Capture Service");
                configurator.SetDisplayName("Applied Systems Risk Capture Service");
                configurator.SetServiceName("Applied Systems Risk Capture Service");
            });
        }
Exemplo n.º 7
0
        static void Main()
        {
            SetupCurrentPrincipalClaims();
            WriteClaimsDescriptionToConsole();

            var eventStoreConfiguration = EventStoreMessageStorageConfiguration.FromAppConfig();

            EventStoreEndpoint eventStoreEndpoint = EventStoreEndpoint
                                                    .OnUrl(EventStoreUrl.Parse(eventStoreConfiguration.Url))
                                                    .WithCredentials(EventStoreUserCredentials.Parse(eventStoreConfiguration.UserCredentials.User, eventStoreConfiguration.UserCredentials.Password))
                                                    .WithEventTypeFromNameResolution(EventTypeFromNameResolver.FromTypesFromAssemblyContaining <PolicyBound>());

            MessagingFramework.Bootstrap()
            .RegisterOutgoingPipelineComponent(new ClaimsToMessageHeadersPipe())
            .ConfigureEventStoreEndpoint(eventStoreEndpoint)
            .ConfigureMessageRouting()
            .Outgoing.ForEvents
            .Send <PolicyBound>()
            .ViaEndpoint(eventStoreEndpoint)
            .ToEventStream(@event => PolicyEventStreamId.Parse(@event.TenantId))
            .Initialise();

            Console.WriteLine("I Am Publisher");


            while (true)
            {
                Console.WriteLine("P = Raise PolicyBound event. Esc = Exit.");
                var key = Console.ReadKey().Key;

                if (key == ConsoleKey.Escape)
                {
                    return;
                }

                if (key == ConsoleKey.P)
                {
                    MessageSendingContext.Bus.Send(new PolicyBound("SimplePubSubExample", "<Risk><DriverName>Darth Vader</DriverName></Risk>"));
                }
            }
        }
Exemplo n.º 8
0
        static void Main()
        {
            var eventStoreConfiguration = EventStoreMessageStorageConfiguration.FromAppConfig();

            EventStoreEndpoint eventStoreEndpoint = EventStoreEndpoint
                                                    .OnUrl(EventStoreUrl.Parse(eventStoreConfiguration.Url))
                                                    .WithCredentials(EventStoreUserCredentials.Parse(eventStoreConfiguration.UserCredentials.User, eventStoreConfiguration.UserCredentials.Password))
                                                    .WithEventTypeFromNameResolution(EventTypeFromNameResolver.FromTypesFromAssemblyContaining <PolicyBound>());


            MessagingFramework.Bootstrap()
            .ConfigureEventStoreEndpoint(eventStoreEndpoint)
            .ConfigureMessageRouting()
            .Outgoing.ForEvents
            .Send <PolicyBound>()
            .ViaEndpoint(eventStoreEndpoint)
            .ToEventStream(@event => TenantPoliciesEventStreamId.Parse(@event.TenantId))
            .Initialise();

            Console.WriteLine("I Am Publisher");

            while (true)
            {
                Console.WriteLine("P = Raise PolicyBound event. Esc = Exit.");
                var key = Console.ReadKey().Key;

                if (key == ConsoleKey.Escape)
                {
                    return;
                }

                if (key == ConsoleKey.P)
                {
                    MessageSendingContext.Bus.Send(new PolicyBound(
                                                       "Tenant2",
                                                       "AX00001011",
                                                       "<Risk><DriverName>Darth Vader</DriverName></Risk>"));
                }
            }
        }
        static void Main(string[] args)
        {
            var eventStoreConfiguration = EventStoreMessageStorageConfiguration.FromAppConfig();

            EventStoreEndpoint eventStoreEndpoint = EventStoreEndpoint
                                                    .OnUrl(EventStoreUrl.Parse(eventStoreConfiguration.Url))
                                                    .WithCredentials(EventStoreUserCredentials.Parse(eventStoreConfiguration.UserCredentials.User, eventStoreConfiguration.UserCredentials.Password))
                                                    .WithEventTypeFromNameResolution(EventTypeFromNameResolver.FromTypesFromAssemblyContaining <AccountCredited>());

            MessagingFramework.Bootstrap()
            .ConfigureEventStoreEndpoint(eventStoreEndpoint)
            .ConfigureMessageRouting()
            .Internal.ForCommands
            .Handle <DepositMoneyIntoAccount>().With <DepositMoneyIntoAccountHandler>()
            .Handle <WithdrawMoneyFromAccount>().With <WithdrawMoneyFromAccountHandler>()
            .Initialise();

            while (true)
            {
                Console.WriteLine("D = Deposit £10 into account. W = Withdraw £10 from account. Esc = Exit.");

                var key = Console.ReadKey().Key;

                if (key == ConsoleKey.Escape)
                {
                    return;
                }

                if (key == ConsoleKey.D)
                {
                    MessageSendingContext.Bus.Send(new DepositMoneyIntoAccount("111111", 10));
                }

                if (key == ConsoleKey.W)
                {
                    MessageSendingContext.Bus.Send(new WithdrawMoneyFromAccount("111111", 10));
                }
            }
        }
        static void Main(string[] args)
        {
            var eventStoreConfiguration = EventStoreSubscriptionConfiguration.FromAppConfig();

            EventStoreSubscriptionEndpoint eventStoreEndpoint = EventStoreSubscriptionEndpoint
                                                                .ListenTo(EventStoreUrl.Parse(eventStoreConfiguration.Url))
                                                                .WithCredentials(EventStoreUserCredentials.Parse(eventStoreConfiguration.UserCredentials.User, eventStoreConfiguration.UserCredentials.Password))
                                                                .WithEventTypeFromNameResolution(EventTypeFromNameResolver.Default())
                                                                .WithInMemoryEventIndexStorage();

            MessagingFramework.Bootstrap()
            .ConfigureReceivingEndpoint(eventStoreEndpoint)
            .RegisterIncomingPipelineComponent(new EventForwarderPipe(new CustomEventProcessor()))
            .Initialise();

            MessageReceivingContext.MessageReceiver.StartReceiving(OnError);
            MessageReceivingContext.Events.Subscribe("CustomPipelineExample1");

            Console.WriteLine("I Am Subscriber");
            Console.ReadLine();

            MessageReceivingContext.MessageReceiver.StopReceiving();
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            var eventStoreConfiguration = EventStoreSubscriptionConfiguration.FromAppConfig();

            EventStorePersistentSubscriptionEndpoint eventStoreEndpoint = EventStorePersistentSubscriptionEndpoint
                                                                          .ListenTo(EventStoreUrl.Parse(eventStoreConfiguration.Url))
                                                                          .WithCredentials(EventStoreUserCredentials.Parse(eventStoreConfiguration.UserCredentials.User, eventStoreConfiguration.UserCredentials.Password))
                                                                          .WithBufferSizeOf(1)
                                                                          .WithEventTypeFromNameResolution(EventTypeFromNameResolver.FromTypesFromAssemblyContaining <PolicyBound>());

            MessagingFramework.Bootstrap()
            .SetupDataConnectivity().WithSqlConnection()
            .SetupMessaging()
            .ConfigureReceivingEndpoint(eventStoreEndpoint)
            .ConfigureMessageRouting().Incoming.ForEvents.Handle <PolicyBound>().With <PolicyBoundHandler>()
            .Initialise();

            MessageReceivingContext.MessageReceiver.StartReceiving(OnError);
            MessageReceivingContext.Events.Subscribe(TenantPolicyEventStreamGroup.Parse("Tenant1"));

            Console.WriteLine("I Am CompetingConsumerSubscriber2");
            Console.ReadLine();

            MessageReceivingContext.MessageReceiver.StopReceiving();
        }