public void PartitionWithRouter()
        {
            var config = new MemoryStorageConfig();
            var raw = new RawEngineBuilder();

            var inWriter = config.CreateQueueWriter("in");
            var doWriter = config.CreateQueueWriter("do");

            // forwarder in => do
            raw.Dispatch(config.CreateInbox("in"), envelope => doWriter.PutMessage(envelope));
            // forwarder do => in
            raw.Dispatch(config.CreateInbox("do"), envelope => inWriter.PutMessage(envelope));

            TestConfiguration(inWriter, raw);
        }
        public void PartitionWithRouter()
        {
            var config = new MemoryStorageConfig();
            var raw    = new CqrsEngineBuilder(EnvelopeStreamer.CreateDefault());

            var inWriter = config.CreateQueueWriter("in");
            var doWriter = config.CreateQueueWriter("do");

            // forwarder in => do
            raw.Dispatch(config.CreateInbox("in"), doWriter.PutMessage);
            // forwarder do => in
            raw.Dispatch(config.CreateInbox("do"), inWriter.PutMessage);


            TestConfiguration(inWriter, raw);
        }
Example #3
0
        public void Run_in_test()
        {
            var streamer = EnvelopeStreamer.CreateDefault(typeof(CreateCustomer), typeof(CustomerCreated));

            var builder = new CqrsEngineBuilder(streamer);
            var account = new MemoryStorageConfig();

            var nuclear = account.CreateNuclear(new TestStrategy());
            var inbox = account.CreateInbox("input");
            var sender = account.CreateSimpleSender(streamer, "input");

            var handler = new RedirectToCommand();
            handler.WireToLambda<CreateCustomer>(customer => Consume(customer, nuclear, sender));
            handler.WireToLambda<CustomerCreated>(m => Console.WriteLine("Created!"));
            builder.Handle(inbox,  envelope => handler.InvokeMany(envelope.SelectContents()));

            using (var engine = builder.Build())
            {
                sender.SendOne(new CreateCustomer
                {
                    CustomerId = 1,
                    CustomerName = "Rinat Abdullin"
                });
                engine.RunForever();
            }
        }
Example #4
0
        public void Run_in_test()
        {
            var streamer = EnvelopeStreamer.CreateDefault(typeof(CreateCustomer), typeof(CustomerCreated));

            var builder = new CqrsEngineBuilder(streamer);
            var account = new MemoryStorageConfig();

            var nuclear = account.CreateNuclear(new TestStrategy());
            var inbox   = account.CreateInbox("input");
            var sender  = account.CreateSimpleSender(streamer, "input");



            var handler = new RedirectToCommand();

            handler.WireToLambda <CreateCustomer>(customer => Consume(customer, nuclear, sender));
            handler.WireToLambda <CustomerCreated>(m => Console.WriteLine("Created!"));
            builder.Handle(inbox, envelope => handler.InvokeMany(envelope.SelectContents()));

            using (var engine = builder.Build())
            {
                sender.SendOne(new CreateCustomer
                {
                    CustomerId   = 1,
                    CustomerName = "Rinat Abdullin"
                });
                engine.RunForever();
            }
        }
        public void RouterChain()
        {
            var config   = new MemoryStorageConfig();
            var raw      = new CqrsEngineBuilder(EnvelopeStreamer.CreateDefault());
            var doWriter = config.CreateQueueWriter("do");

            var route1 = config.CreateQueueWriter("route1");
            var route2 = config.CreateQueueWriter("route2");

            // in => (route1 OR route2)
            raw.Dispatch(config.CreateInbox("in"), bytes => LoadBalance(bytes, route1, route2));
            // forwarder (route1,route2) => do
            raw.Dispatch(config.CreateInbox("route1", "route2"), doWriter.PutMessage);

            raw.Dispatch(config.CreateInbox("do"), bytes => LoadBalance(bytes, route1, route2));
            TestConfiguration(config.CreateQueueWriter("in"), raw);
        }
        public void RouterChain()
        {
            var config = new MemoryStorageConfig();
            var raw = new RawEngineBuilder();
            var doWriter = config.CreateQueueWriter("do");

            var route1 = config.CreateQueueWriter("route1");
            var route2 = config.CreateQueueWriter("route2");

            // in => (route1 OR route2)
            raw.Dispatch(config.CreateInbox("in"), bytes => LoadBalance(bytes, route1, route2));
            // forwarder (route1,route2) => do
            raw.Dispatch(config.CreateInbox("route1", "route2"), envelope => doWriter.PutMessage(envelope));

            raw.Dispatch(config.CreateInbox("do"), bytes => LoadBalance(bytes, route1, route2));
            TestConfiguration(config.CreateQueueWriter("in"), raw);
        }
        public void Direct()
        {
            var config = new MemoryStorageConfig();
            var raw = new CqrsEngineBuilder(EnvelopeStreamer.CreateDefault());
            var doWriter = config.CreateQueueWriter("do");

            // forwarder do => do
            raw.Dispatch(config.CreateInbox("do"), doWriter.PutMessage);
            TestConfiguration(doWriter, raw);
        }
        public void Memory_lambda()
        {
            var config = new MemoryStorageConfig();
            var writer = config.CreateQueueWriter("test");
            var inbox = config.CreateInbox("test");

            var builder = new CqrsEngineBuilder(null);
            builder.Dispatch(inbox, bytes => { });

            var setup = new Setup
                {
                    Send = i => writer.PutMessage(new[] {i}),
                    Engine = builder.Build()
                };

            TestConfiguration(setup, 1000000);
        }
        public void Memory_lambda()
        {
            var config = new MemoryStorageConfig();
            var writer = config.CreateQueueWriter("test");
            var inbox  = config.CreateInbox("test");

            var builder = new CqrsEngineBuilder(null);

            builder.Dispatch(inbox, bytes => { });

            var setup = new Setup
            {
                Send   = i => writer.PutMessage(new[] { i }),
                Engine = builder.Build()
            };

            TestConfiguration(setup, 1000000);
        }