public void Cannot_be_combined_with_time_to_be_received()
        {
            var behavior = new RouteDeferredMessageToTimeoutManagerBehavior("tm");
            var delay = TimeSpan.FromDays(1);

            var context = CreateContext(new UnicastRoutingStrategy("target"), new DelayDeliveryWith(delay), new DiscardIfNotReceivedBefore(TimeSpan.FromSeconds(30)));

            Assert.That(async () => await behavior.Invoke(context, ctx => TaskEx.CompletedTask), Throws.InstanceOf<Exception>().And.Message.Contains("Postponed delivery of messages with TimeToBeReceived set is not supported. Remove the TimeToBeReceived attribute to postpone messages of this type."));
        }
Пример #2
0
        public void Supports_only_unicast_routing()
        {
            var behavior = new RouteDeferredMessageToTimeoutManagerBehavior("tm");
            var delay    = TimeSpan.FromDays(1);

            var context = CreateContext(new MulticastRoutingStrategy(null), new DelayDeliveryWith(delay));

            Assert.That(async() => await behavior.Invoke(context, ctx => Task.CompletedTask), Throws.InstanceOf <Exception>().And.Message.Contains("Delayed delivery using the Timeout Manager is only supported for messages with unicast routing"));
        }
        public void Supports_only_unicast_routing()
        {
            var behavior = new RouteDeferredMessageToTimeoutManagerBehavior("tm");
            var delay = TimeSpan.FromDays(1);

            var context = CreateContext(new MulticastRoutingStrategy(null), new DelayDeliveryWith(delay));

            Assert.That(async () => await behavior.Invoke(context, ctx => TaskEx.CompletedTask), Throws.InstanceOf<Exception>().And.Message.Contains("Delayed delivery using the Timeout Manager is only supported for messages with unicast routing"));
        }
        public void Cannot_be_combined_with_time_to_be_received()
        {
            var behavior = new RouteDeferredMessageToTimeoutManagerBehavior("tm");
            var delay    = TimeSpan.FromDays(1);

            var context = CreateContext(new UnicastRoutingStrategy("target"), new DelayDeliveryWith(delay), new DiscardIfNotReceivedBefore(TimeSpan.FromSeconds(30)));

            Assert.That(async() => await behavior.Invoke(context, ctx => TaskEx.CompletedTask), Throws.InstanceOf <Exception>().And.Message.Contains("Postponed delivery of messages with TimeToBeReceived set is not supported. Remove the TimeToBeReceived attribute to postpone messages of this type."));
        }
        public async Task Should_set_the_expiry_header_to_a_absolute_utc_time()
        {
            var behavior = new RouteDeferredMessageToTimeoutManagerBehavior("tm");
            var at = DateTime.UtcNow + TimeSpan.FromDays(1);

            var headers = new Dictionary<string, string>();
            var context = CreateContext(new UnicastRoutingStrategy("target"), new DoNotDeliverBefore(at));

            await behavior.Invoke(context, c =>
            {
                c.RoutingStrategies.First().Apply(headers);
                return TaskEx.CompletedTask;
            });

            Assert.AreEqual(headers[TimeoutManagerHeaders.Expire], DateTimeExtensions.ToWireFormattedString(at));
        }
        public async Task Should_set_the_expiry_header_to_a_absolute_utc_time_calculated_based_on_delay()
        {
            var behavior = new RouteDeferredMessageToTimeoutManagerBehavior("tm");
            var delay = TimeSpan.FromDays(1);

            var headers = new Dictionary<string, string>();
            var context = CreateContext(new UnicastRoutingStrategy("target"), new DelayDeliveryWith(delay));

            await behavior.Invoke(context, c =>
            {
                c.RoutingStrategies.First().Apply(headers);
                return TaskEx.CompletedTask;
            });

            Assert.LessOrEqual(DateTimeExtensions.ToUtcDateTime(headers[TimeoutManagerHeaders.Expire]), DateTime.UtcNow + delay);
        }
Пример #7
0
        public async Task Should_set_the_expiry_header_to_a_absolute_utc_time()
        {
            var behavior = new RouteDeferredMessageToTimeoutManagerBehavior("tm");
            var at       = DateTime.UtcNow + TimeSpan.FromDays(1);

            var headers = new Dictionary <string, string>();
            var context = CreateContext(new UnicastRoutingStrategy("target"), new DoNotDeliverBefore(at));

            await behavior.Invoke(context, c =>
            {
                c.RoutingStrategies.First().Apply(headers);
                return(Task.CompletedTask);
            });

            Assert.AreEqual(headers[TimeoutManagerHeaders.Expire], DateTimeExtensions.ToWireFormattedString(at));
        }
Пример #8
0
        public async Task Should_set_the_expiry_header_to_a_absolute_utc_time_calculated_based_on_delay()
        {
            var behavior = new RouteDeferredMessageToTimeoutManagerBehavior("tm");
            var delay    = TimeSpan.FromDays(1);

            var headers = new Dictionary <string, string>();
            var context = CreateContext(new UnicastRoutingStrategy("target"), new DelayDeliveryWith(delay));

            await behavior.Invoke(context, c =>
            {
                c.RoutingStrategies.First().Apply(headers);
                return(Task.CompletedTask);
            });

            Assert.LessOrEqual(DateTimeExtensions.ToUtcDateTime(headers[TimeoutManagerHeaders.Expire]), DateTime.UtcNow + delay);
        }
        public async Task Should_reroute_to_the_timeout_manager()
        {
            var behavior = new RouteDeferredMessageToTimeoutManagerBehavior("tm");
            var delay = TimeSpan.FromDays(1);

            var headers = new Dictionary<string, string>();
            string destination = null;
            var context = CreateContext(new UnicastRoutingStrategy("target"), new DelayDeliveryWith(delay));

            await behavior.Invoke(context, c =>
            {
                var addressTag = (UnicastAddressTag) c.RoutingStrategies.First().Apply(headers);
                destination = addressTag.Destination;
                return TaskEx.CompletedTask;
            });

            Assert.AreEqual("tm", destination);
            Assert.AreEqual(headers[TimeoutManagerHeaders.RouteExpiredTimeoutTo], "target");
        }
Пример #10
0
        public async Task Should_reroute_to_the_timeout_manager()
        {
            var behavior = new RouteDeferredMessageToTimeoutManagerBehavior("tm");
            var delay    = TimeSpan.FromDays(1);

            var    headers     = new Dictionary <string, string>();
            string destination = null;
            var    context     = CreateContext(new UnicastRoutingStrategy("target"), new DelayDeliveryWith(delay));

            await behavior.Invoke(context, c =>
            {
                var addressTag = (UnicastAddressTag)c.RoutingStrategies.First().Apply(headers);
                destination    = addressTag.Destination;
                return(Task.CompletedTask);
            });

            Assert.AreEqual("tm", destination);
            Assert.AreEqual(headers[TimeoutManagerHeaders.RouteExpiredTimeoutTo], "target");
        }