private static void Main() { CloudStorageAccount account = CloudStorageAccount.Parse("UseDevelopmentStorage=true"); IAzureStorageConfig storageConfig = AzureStorage.CreateConfig(account); var builder = new CqrsClientBuilder(); builder.UseProtoBufSerialization(); builder.Domain(m => m.InAssemblyOf <MessageCreated>()); builder.Azure(config => config.AddAzureSender(storageConfig, Queues.MESSAGES)); builder.Storage(config => config.AtomicIsInAzure(storageConfig, s => { s.WithAssemblyOf <MessageView>(); s.CustomStaticSerializer(new AtomicStorageSerializerWithProtoBuf()); })); builder.Advanced.ConfigureContainer(b => { b.RegisterType <Program>().As <Program>(); b.RegisterInstance(storageConfig).As <IAzureStorageConfig>(); //This is solely to show the replaying of events. You wouldn't ordinarily need the eventstore in a cqrs client; b.RegisterInstance(ConfigureEventStore()).SingleInstance().As <IStoreEvents>(); }); CqrsClient cqrsClient = builder.Build(); ILifetimeScope scope = cqrsClient.Scope; scope.Resolve <Program>().Run(); }
private static void Main() { CloudStorageAccount account = CloudStorageAccount.Parse("UseDevelopmentStorage=true"); IAzureStorageConfig storageConfig = AzureStorage.CreateConfig(account); var builder = new CqrsClientBuilder(); builder.UseProtoBufSerialization(); builder.Domain(m => m.InAssemblyOf<MessageCreated>()); builder.Azure(config => config.AddAzureSender(storageConfig, Queues.MESSAGES)); builder.Storage(config => config.AtomicIsInAzure(storageConfig, s => { s.WithAssemblyOf<MessageView>(); s.CustomStaticSerializer(new AtomicStorageSerializerWithProtoBuf()); })); builder.Advanced.ConfigureContainer(b => { b.RegisterType<Program>().As<Program>(); b.RegisterInstance(storageConfig).As<IAzureStorageConfig>(); //This is solely to show the replaying of events. You wouldn't ordinarily need the eventstore in a cqrs client; b.RegisterInstance(ConfigureEventStore()).SingleInstance().As<IStoreEvents>(); }); CqrsClient cqrsClient = builder.Build(); ILifetimeScope scope = cqrsClient.Scope; scope.Resolve<Program>().Run(); }
public void Test() { var dev = AzureStorage.CreateConfigurationForDev(); WipeAzureAccount.Fast(s => s.StartsWith("test-"), dev); var events = new Subject <ISystemEvent>(); var b = new CqrsEngineBuilder(); b.Azure(c => c.AddAzureProcess(dev, "test-publish")); b.Advanced.RegisterObserver(events); var engine = b.Build(); var source = new CancellationTokenSource(); engine.Start(source.Token); var builder = new CqrsClientBuilder(); builder.Azure(c => c.AddAzureSender(dev, "test-publish")); var client = builder.Build(); client.Sender.SendOne(new Message()); using (engine) using (events.OfType <EnvelopeAcked>().Subscribe(e => source.Cancel())) { source.Token.WaitHandle.WaitOne(5000); source.Cancel(); } }