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() { 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>")); } } }
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)); }