Exemple #1
0
        protected static void SmartFailing(FailingMessage message, NuclearStorage storage)
        {
            var status = storage.GetSingletonOrNew <int>();

            if (status < message.FailXTimes)
            {
                storage.AddOrUpdateSingleton(() => 1, i => i + 1);
                throw new InvalidOperationException("Failure requested");
            }
        }
Exemple #2
0
            public void Consume(Message message)
            {
                var count = _storage.AddOrUpdateSingleton(() => 1, i => i + 1);

                if (count < 4)
                {
                    throw new InvalidOperationException("Fail");
                }

                _sender.SendOne(new Message(), cb => cb.AddString("finish"));
            }
        protected static void Consume(Act message, NuclearStorage storage)
        {
            new TransactionTester
                {
                    OnCommit = () =>
                        {
                            var singleton = storage.AddOrUpdateSingleton(() => 1, i => i + 1);
                            Trace.WriteLine("Commit kicked " + singleton);
                        }
                };

            if (message.Fail)
                throw new InvalidOperationException("Fail requested");
        }
        protected static void Consume(Act message, NuclearStorage storage)
        {
            new TransactionTester
            {
                OnCommit = () =>
                {
                    var singleton = storage.AddOrUpdateSingleton(() => 1, i => i + 1);
                    Trace.WriteLine("Commit kicked " + singleton);
                }
            };

            if (message.Fail)
            {
                throw new InvalidOperationException("Fail requested");
            }
        }
        void VerifyNonAtomic(NuclearStorage storage)
        {
            storage.AddOrUpdateEntity(1, new Entity());
            storage.GetEntity<Entity>(1);
            storage.UpdateEntity<Entity>(1, e => e.Do());
            storage.TryDeleteEntity<Entity>(1);

            storage.AddOrUpdateSingleton(() => new Entity(), e => e.Do());
            storage.UpdateSingletonEnforcingNew<Entity>(e => e.Do());
            storage.GetSingleton<Entity>();
            storage.TryDeleteSingleton<Entity>();
            storage.UpdateSingleton<Entity>(e => e.Do());

            //storage.UpdateOrAddEntity<Entity>(1, e => e.Do());
            //storage.TryDelete<Entity>(1);

            //storage.SaveSingleton(new Entity());
            //storage.GetSingleton<Entity>();
            //storage.UpdateSingleton<Entity>(e => e.Do());
            //storage.TryDeleteSingleton<Entity>();
        }
Exemple #6
0
        public void Consume(MessageCreated message)
        {
            Trace.TraceInformation("DENORMALIZING MESSAGE CREATED EVENT {0}[{1}]...", message.Message, message.Id);

            MyMessageContext context = contextFactory();

            var entity = new MessageView
            {
                Context    = context,
                Message    = message.Message,
                UtcCreated = message.UtcCreated
            };

            storage.AddOrUpdateEntity(message.Id, entity);

            storage.AddOrUpdateSingleton(() =>
            {
                var index = new MessageIndex();
                index.Messages.Add(message.Id, message.Message);
                return(index);
            }, i => i.Messages[message.Id] = message.Message);
        }
 protected static void HandleNuclear(NuclearMessage msg, SimpleMessageSender sender, NuclearStorage storage)
 {
     var count = storage.AddOrUpdateSingleton(() => 1, i => i + 1);
     if (count >= 2)
     {
         sender.SendBatch(new object[] {}, e => e.AddString("ok"));
         return;
     }
     sender.SendOne(new NuclearMessage());
 }
 protected static void SmartFailing(FailingMessage message, NuclearStorage storage)
 {
     var status = storage.GetSingletonOrNew<int>();
     if (status < message.FailXTimes)
     {
         storage.AddOrUpdateSingleton(() => 1, i => i + 1);
         throw new InvalidOperationException("Failure requested");
     }
 }