示例#1
0
            public async Task UnacknowledgedCommandWithNonExpiredRetryPolicyIsRetriedAcrossAdditionalStarts()
            {
                var command = new TestDurableCommand(SingleValue);
                await _bus.SendDurable(command);

                Assume.That(_commands.ProcessedMessagePayload, Is.EqualTo(SingleValue));

                await _bus.Start();

                Assert.That(_commands.ProcessedMessagePayload, Is.EqualTo(string.Format("{0}{0}", SingleValue)));
            }
示例#2
0
            public async Task CommandAndEventAreRetriedOnNextStart()
            {
                await _bus.SendDurable(new TestDurableCommand(SingleValue));

                await _bus.PublishDurable(new TestDurableEvent(SingleValue));

                Assume.That(_commands.ProcessedMessagePayload, Is.EqualTo(SingleValue));
                Assume.That(_events.ProcessedMessagePayload, Is.EqualTo(SingleValue));

                await _bus.Start();

                Assert.That(_commands.ProcessedMessagePayload, Is.EqualTo(_doubleValue));
                Assert.That(_events.ProcessedMessagePayload, Is.EqualTo(_doubleValue));
            }
示例#3
0
            public async Task CommandAndEventAreNotRetriedAcrossAdditionalStarts()
            {
                await _bus.SendDurable(new TestDurableCommand(SingleValue));

                await _bus.PublishDurable(new TestDurableEvent(SingleValue));

                Assume.That(_commands.ProcessedMessagePayload, Is.EqualTo(SingleValue));
                Assume.That(_events.ProcessedMessagePayload, Is.EqualTo(SingleValue));

                //despite multiple calls to Start(), messages are NOT retried at all as per the retry policy setting
                for (int i = 0; i < 10; i++)
                {
                    await _bus.Start();
                }

                Assert.That(_commands.ProcessedMessagePayload, Is.EqualTo(SingleValue));
                Assert.That(_events.ProcessedMessagePayload, Is.EqualTo(SingleValue));
            }
示例#4
0
            public async Task MessageIsNotSendToSubscriberOnStart()
            {
                const string singleValue = "0";

                //we need a retry policy with at least one retry
                //  so that we'd expect the call to Start() to attempt a retry
                var retryPolicy = new RetryPolicy(1, DateTimeUtility.PositiveOneHourTimeSpan);

                var bus      = new DurableMessageBus(retryPolicy);
                var commands = new CommandSubscribers();

                bus.RegisterSubscriptionFor <TestDurableCommand>(commands.Handle);

                await bus.SendDurable(new TestDurableCommand(singleValue));

                Assume.That(commands.ProcessedMessagePayload, Is.EqualTo(singleValue), "Command Subscriber didn't receive the expected message.");

                bus.UnRegisterAllSubscriptionsFor <TestDurableCommand>();

                await bus.Start();

                Assert.That(commands.ProcessedMessagePayload, Is.EqualTo(singleValue), "Bus did not properly ignore queued command.");
            }
示例#5
0
            private async Task SendUnacknowledgedCommandAndEventTwiceThenDisposeDurableBus()
            {
                _doubleValue = string.Format("{0}{0}", SingleValue);
                _tripleValue = string.Format("{0}{0}{0}", SingleValue);

                _retryPolicy = new RetryPolicy(10, DateTimeUtility.PositiveOneHourTimeSpan);
                _bus         = new DurableMessageBus(_retryPolicy);

                _commands = new DurableCommandSubscribers();
                _events   = new DurableEventSubscribers();

                _bus.RegisterSubscriptionFor <TestDurableCommand>(_commands.Handle);
                _bus.RegisterSubscriptionFor <TestDurableEvent>(_events.Handle);

                await _bus.SendDurable(new TestDurableCommand(SingleValue));

                await _bus.PublishDurable(new TestDurableEvent(SingleValue));

                Assume.That(_commands.ProcessedMessagePayload, Is.EqualTo(SingleValue),
                            "Command Subscriber not registered for command as expected.");
                Assume.That(_events.ProcessedMessagePayload, Is.EqualTo(SingleValue),
                            "Event Subscriber not registered for event as expected.");

                await _bus.Start();

                Assume.That(_commands.ProcessedMessagePayload, Is.EqualTo(_doubleValue),
                            "Command Subscriber not registered for command as expected.");
                Assume.That(_events.ProcessedMessagePayload, Is.EqualTo(_doubleValue),
                            "Event Subscriber not registered for event as expected.");

                await _bus.Stop();

                _bus = null;

                Assume.That(_bus, Is.Null);
            }