Beispiel #1
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();
        }
Beispiel #2
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();
        }
Beispiel #3
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();
        }
Beispiel #4
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>"));
                }
            }
        }
Beispiel #5
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()
            .SetupMessaging()
            .ConfigureEventStoreEndpoint(eventStoreEndpoint)
            .ConfigureMessageRouting()
            .Outgoing.ForEvents
            .Send <PolicyBound>()
            .ViaEndpoint(eventStoreEndpoint)
            .ToEventStream(@event => PolicyEventStreamId.Parse(@event.PolicyNumber))
            .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(Guid.NewGuid(), "Tenant1", "<Risk><DriverName>Darth Vader</DriverName></Risk>"));
                }
            }
        }