コード例 #1
0
        public void Should_process_the_saga_normally()
        {
            Guid transactionId = NewId.NextGuid();

            Trace.WriteLine("Creating transaction for " + transactionId);

            int startValue = 1;

            var startConcurrentSaga = new StartConcurrentSaga
            {
                CorrelationId = transactionId, Name = "Chris", Value = startValue
            };

            LocalBus.Publish(startConcurrentSaga);
            Trace.WriteLine("Just published the start message");

            _sagaRepository.ShouldContainSaga(transactionId).ShouldNotBeNull();

            int nextValue = 2;
            var continueConcurrentSaga = new ContinueConcurrentSaga {
                CorrelationId = transactionId, Value = nextValue
            };

            LocalBus.Publish(continueConcurrentSaga);
            Trace.WriteLine("Just published the continue message");

            ConcurrentSaga saga = _sagaRepository
                                  .ShouldContainSaga(x => x.CorrelationId == transactionId && x.Value == nextValue);

            saga.ShouldNotBeNull();
            saga.ShouldBeInState(ConcurrentSaga.Completed);
        }
コード例 #2
0
        public void Should_process_the_messages_in_order_and_not_at_the_same_time()
        {
            Guid transactionId = NewId.NextGuid();

            Trace.WriteLine("Creating transaction for " + transactionId);

            int startValue = 1;

            var startConcurrentSaga = new StartConcurrentSaga
            {
                CorrelationId = transactionId, Name = "Chris", Value = startValue
            };

            LocalBus.Publish(startConcurrentSaga);
            LocalBus.Publish(startConcurrentSaga);
            Trace.WriteLine("Just published the start message");

            _sagaRepository.ShouldContainSaga(transactionId).ShouldNotBeNull();

            int nextValue = 2;
            var continueConcurrentSaga = new ContinueConcurrentSaga {
                CorrelationId = transactionId, Value = nextValue
            };

            LocalBus.Publish(continueConcurrentSaga);
            Trace.WriteLine("Just published the continue message");

            _sagaRepository.ShouldContainSaga(x => x.CorrelationId == transactionId && x.Value == nextValue).
            ShouldNotBeNull();

            Thread.Sleep(8000);

            LocalEndpoint.ShouldNotContain <StartConcurrentSaga>();
            LocalErrorEndpoint.ShouldContain <StartConcurrentSaga>();
        }
コード例 #3
0
        public void Should_process_the_messages_in_order_and_not_at_the_same_time()
        {
            Guid transactionId = NewId.NextGuid();

            Trace.WriteLine("Creating transaction for " + transactionId);

            int startValue = 1;

            var startConcurrentSaga = new StartConcurrentSaga
                {CorrelationId = transactionId, Name = "Chris", Value = startValue};

            LocalBus.Publish(startConcurrentSaga);
            LocalBus.Publish(startConcurrentSaga);
            Trace.WriteLine("Just published the start message");

            _sagaRepository.ShouldContainSaga(transactionId).ShouldNotBeNull();

            int nextValue = 2;
            var continueConcurrentSaga = new ContinueConcurrentSaga {CorrelationId = transactionId, Value = nextValue};

            LocalBus.Publish(continueConcurrentSaga);
            Trace.WriteLine("Just published the continue message");

            _sagaRepository.ShouldContainSaga(x => x.CorrelationId == transactionId && x.Value == nextValue).
                ShouldNotBeNull();

            Thread.Sleep(8000);

            LocalEndpoint.ShouldNotContain<StartConcurrentSaga>();
            LocalErrorEndpoint.ShouldContain<StartConcurrentSaga>();
        }
コード例 #4
0
        public void Should_process_the_messages_in_order_and_not_at_the_same_time()
        {
            Guid transactionId = CombGuid.Generate();

            _log.Info("Creating transaction for " + transactionId);

            const int startValue = 1;

            var startConcurrentSaga = new StartConcurrentSaga {
                CorrelationId = transactionId, Name = "Chris", Value = startValue
            };

            LocalBus.Endpoint.Send(startConcurrentSaga);
            LocalBus.Endpoint.Send(startConcurrentSaga);

            _log.Info("Just published the start message");

            UnsubscribeAction unsubscribeAction = LocalBus.Subscribe <ConcurrentLegacySaga>();

            Thread.Sleep(1500);

            const int nextValue = 2;
            var       continueConcurrentSaga = new ContinueConcurrentSaga {
                CorrelationId = transactionId, Value = nextValue
            };

            LocalBus.Publish(continueConcurrentSaga);
            _log.Info("Just published the continue message");
            Thread.Sleep(8000);

            unsubscribeAction();
            foreach (ConcurrentLegacySaga saga in _sagaRepository.Where(x => true))
            {
                _log.Info("Found saga: " + saga.CorrelationId);
            }

            int currentValue = _sagaRepository.Where(x => x.CorrelationId == transactionId).First().Value;

            Assert.AreEqual(nextValue, currentValue);
        }
コード例 #5
0
		public void Should_process_the_messages_in_order_and_not_at_the_same_time()
		{
			Guid transactionId = CombGuid.Generate();

			_log.Info("Creating transaction for " + transactionId);

			const int startValue = 1;

			var startConcurrentSaga = new StartConcurrentSaga {CorrelationId = transactionId, Name = "Chris", Value = startValue};

			LocalBus.Endpoint.Send(startConcurrentSaga);
			LocalBus.Endpoint.Send(startConcurrentSaga);

			_log.Info("Just published the start message");

			UnsubscribeAction unsubscribeAction = LocalBus.Subscribe<ConcurrentLegacySaga>();

			Thread.Sleep(1500);

			const int nextValue = 2;
			var continueConcurrentSaga = new ContinueConcurrentSaga {CorrelationId = transactionId, Value = nextValue};

			LocalBus.Publish(continueConcurrentSaga);
			_log.Info("Just published the continue message");
			Thread.Sleep(8000);

			unsubscribeAction();
			foreach (ConcurrentLegacySaga saga in _sagaRepository.Where(x => true))
			{
				_log.Info("Found saga: " + saga.CorrelationId);
			}

			int currentValue = _sagaRepository.Where(x => x.CorrelationId == transactionId).First().Value;

			Assert.AreEqual(nextValue, currentValue);
		}
コード例 #6
0
        public void Should_process_the_messages_in_order_and_not_at_the_same_time()
        {
            UnsubscribeAction unsubscribeAction = LocalBus.SubscribeSaga(_sagaRepository);

            Guid transactionId = NewId.NextGuid();

            Trace.WriteLine("Creating transaction for " + transactionId);

            int startValue = 1;

            var startConcurrentSaga = new StartConcurrentSaga
                {CorrelationId = transactionId, Name = "Chris", Value = startValue};

            LocalBus.Publish(startConcurrentSaga);
            Trace.WriteLine("Just published the start message");

            Thread.Sleep(1500);

            int nextValue = 2;
            var continueConcurrentSaga = new ContinueConcurrentSaga {CorrelationId = transactionId, Value = nextValue};

            LocalBus.Publish(continueConcurrentSaga);
            Trace.WriteLine("Just published the continue message");
            Thread.Sleep(8000);

            unsubscribeAction();
            foreach (ConcurrentSaga saga in _sagaRepository.Where(x => true))
            {
                Trace.WriteLine("Found saga: " + saga.CorrelationId);
            }

            int currentValue = _sagaRepository.Where(x => x.CorrelationId == transactionId).First().Value;

            Assert.AreEqual(nextValue, currentValue);
        }
コード例 #7
0
        public void Should_process_the_messages_in_order_and_not_at_the_same_time()
        {
            UnsubscribeAction unsubscribeAction = LocalBus.SubscribeSaga(_sagaRepository);

            Guid transactionId = NewId.NextGuid();

            Trace.WriteLine("Creating transaction for " + transactionId);

            int startValue = 1;

            var startConcurrentSaga = new StartConcurrentSaga
                {CorrelationId = transactionId, Name = "Chris", Value = startValue};

            LocalBus.Publish(startConcurrentSaga);

            var saga = _sagaRepository.ShouldContainSaga(transactionId, 8.Seconds());
            Assert.IsNotNull(saga);

            int nextValue = 2;
            var continueConcurrentSaga = new ContinueConcurrentSaga {CorrelationId = transactionId, Value = nextValue};

            LocalBus.Publish(continueConcurrentSaga);

            saga = _sagaRepository.ShouldContainSaga(x => x.CorrelationId == transactionId && x.Value == nextValue, 8.Seconds());
            Assert.IsNotNull(saga);

            unsubscribeAction();

            Assert.AreEqual(nextValue, saga.Value);
        }
コード例 #8
0
        public void Should_process_the_saga_normally()
        {
            Guid transactionId = NewId.NextGuid();

            Trace.WriteLine("Creating transaction for " + transactionId);

            int startValue = 1;

            var startConcurrentSaga = new StartConcurrentSaga
                {CorrelationId = transactionId, Name = "Chris", Value = startValue};

            LocalBus.Publish(startConcurrentSaga);
            Trace.WriteLine("Just published the start message");

            _sagaRepository.ShouldContainSaga(transactionId).ShouldNotBeNull();

            int nextValue = 2;
            var continueConcurrentSaga = new ContinueConcurrentSaga {CorrelationId = transactionId, Value = nextValue};

            LocalBus.Publish(continueConcurrentSaga);
            Trace.WriteLine("Just published the continue message");

            ConcurrentSaga saga = _sagaRepository
                .ShouldContainSaga(x => x.CorrelationId == transactionId && x.Value == nextValue);
            saga.ShouldNotBeNull();
            saga.ShouldBeInState(ConcurrentSaga.Completed);
        }