static void Main(string[] args) { var eventStoreConfiguration = EventStoreMessageStorageConfiguration.FromAppConfig(); var eventStoreSubscriptionConfiguration = EventStoreSubscriptionConfiguration.FromAppConfig(); EventStoreEndpoint eventStoreEndpoint = EventStoreEndpoint .OnUrl(EventStoreUrl.Parse(eventStoreConfiguration.Url)) .WithCredentials(EventStoreUserCredentials.Parse(eventStoreConfiguration.UserCredentials.User, eventStoreConfiguration.UserCredentials.Password)) .WithEventTypeFromNameResolution(EventTypeFromNameResolver.FromTypesFromAssemblyContaining <PolicyBound>()); EventStoreSubscriptionEndpoint eventStoreSubscriptionEndpoint = EventStoreSubscriptionEndpoint .ListenTo(EventStoreUrl.Parse(eventStoreSubscriptionConfiguration.Url)) .WithCredentials(EventStoreUserCredentials.Parse(eventStoreSubscriptionConfiguration.UserCredentials.User, eventStoreSubscriptionConfiguration.UserCredentials.Password)) .WithEventTypeFromNameResolution(EventTypeFromNameResolver.FromTypesFromAssemblyContaining <PolicyBound>()) .WithEventStoreEventIndexStorage(); MessagingFramework.Bootstrap() .SetupDataConnectivity().WithSqlConnection() .SetupMessaging() .ConfigureEventStoreEndpoint(eventStoreEndpoint) .ConfigureReceivingEndpoint(eventStoreSubscriptionEndpoint) .ConfigureMessageRouting().Incoming.ForEvents.Handle <PolicyBound>().With <PolicyBoundHandler>() .Initialise(); MessageReceivingContext.MessageReceiver.StartReceiving(OnError); MessageReceivingContext.Events.Subscribe(PolicyEventStreamId.Parse("EventIndexStorageExample")); Console.WriteLine("I Am SubscriberWithServerEventIndexStorage"); Console.ReadLine(); MessageReceivingContext.MessageReceiver.StopReceiving(); }
static void Main(string[] args) { var container = new IocContainer(); container.RegisterInstance <IThirdPartyLibrary, ThirdPartyLibrary>(); var storeConfiguration = EventStoreMessageStorageConfiguration.FromAppConfig(); EventStoreEndpoint storeEndpoint = EventStoreEndpoint .OnUrl(EventStoreUrl.Parse(storeConfiguration.Url)) .WithCredentials(EventStoreUserCredentials.Parse(storeConfiguration.UserCredentials.User, storeConfiguration.UserCredentials.Password)) .WithEventTypeFromNameResolution(EventTypeFromNameResolver.FromTypesFromAssemblyContaining <PolicyBound>()); var storeSubscriptionConfiguration = EventStoreSubscriptionConfiguration.FromAppConfig(); EventStoreSubscriptionEndpoint storeSubscriberEndpoint = EventStoreSubscriptionEndpoint .ListenTo(EventStoreUrl.Parse(storeSubscriptionConfiguration.Url)) .WithCredentials(EventStoreUserCredentials.Parse(storeSubscriptionConfiguration.UserCredentials.User, storeSubscriptionConfiguration.UserCredentials.Password)) .WithEventTypeFromNameResolution(EventTypeFromNameResolver.FromTypesFromAssemblyContaining <PolicyBound>()) .WithInMemoryEventIndexStorage(); MessagingFramework.Bootstrap() .ConfigureEventStoreEndpoint(storeEndpoint) .ConfigureReceivingEndpoint(storeSubscriberEndpoint) .ConfigureMessageRouting().ForSubscriber(container) .Initialise(); MessageReceivingContext.MessageReceiver.StartReceiving(OnError); MessageReceivingContext.Events.Subscribe(TenantPoliciesEventStreamId.Parse("Tenant2")); 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"); }); }
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>")); } } }
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)); } } }