Exemplo n.º 1
0
        private static void SpawnWriters(IBus bus, int threads, int snapshotInterval)
        {
            var stats = new Statistics("Write", snapshotInterval);

            stats.Start();

            for (int i = 0; i < threads; i++)
            {
                new Thread(() =>
                {
                    while (true)
                    {
                        bus.Send(new SampleMessage());
                        writerMetric.Mark();
                        stats.MessageProcessed();
                    }
                }).Start();
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Messages.Metrics.Init();
            var cfg = new BusConfiguration();

            cfg.UsePersistence<InMemoryPersistence>();
            cfg.UseSerialization<JsonSerializer>();
            cfg.UseTransport<SqlServerTransport>();
            cfg.DisableFeature<Audit>();
            cfg.Transactions().DisableDistributedTransactions();
            cfg.Conventions()
                .DefiningMessagesAs(t => t.Namespace != null && t.Namespace.EndsWith("Messages"));

            var stats = new Statistics("Read", 1000);

            stats.Start();

            cfg.RegisterComponents(c => c.RegisterSingleton(stats));

            using (var bus = Bus.Create(cfg).Start())
            {
                Console.Read();
            }
        }