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(); }
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(); }
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(); }
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(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(); }
public static void MessageListener() { Issue objIssue = null; MessagingFramework messagingServices = new MessagingFramework(); messagingServices.ProcessName = "AnalysisService"; messagingServices.CreateQueues(); while (true) { objIssue = (Issue)messagingServices.ReceiveBusinessObject(); //perform analysis on issue object Thread.Sleep(1000); } return; }
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)); } } }
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(); }
public void Setup() { testThirdPartyLibrary = new TestThirdPartyLibrary(); var container = new IocContainer(); container.RegisterInstance <IThirdPartyLibrary>(() => testThirdPartyLibrary); var eventStoreContext = new InProcessEventStoreContext(new InProcessMessageSendContext()); InProcessEventStoreEndpoint storeEndpoint = InProcessEventStoreEndpoint.UsingContext(eventStoreContext); InProcessEventStoreSubscriptionEndpoint storeSubscriberEndpoint = InProcessEventStoreSubscriptionEndpoint.UsingContext(eventStoreContext); MessagingFramework.Bootstrap() .ConfigureEventStoreEndpoint(storeEndpoint) .ConfigureReceivingEndpoint(storeSubscriberEndpoint) .ConfigureMessageRouting() .ForSubscriber(container) .Outgoing.ForEvents.Send <PolicyBound>().ToEventStream(TenantPoliciesEventStreamId.Parse(TenantId)).ViaEndpoint(storeEndpoint) .Initialise(); MessageReceivingContext.MessageReceiver.StartReceiving((_, __) => { }); MessageReceivingContext.Events.Subscribe(TenantPoliciesEventStreamId.Parse(TenantId)); }