Beispiel #1
0
 private static void AddCustomMessageProperties(MessageHandlerMapping messageHandlerMapping, CorrelationRuleFilter filter)
 {
     if (messageHandlerMapping.SubscriptionFilter != null)
     {
         foreach (var property in messageHandlerMapping.SubscriptionFilter.MessageProperties)
         {
             filter.ApplicationProperties.Add(property.Key, property.Value);
         }
     }
 }
Beispiel #2
0
 private void AddMessageFilterProperties(MessageHandlerMapping messageHandlerMapping, Type messageType,
                                         CorrelationRuleFilter filter)
 {
     if (messageHandlerMapping.SubscriptionFilter?.MessageProperties.Count > 0)
     {
         AddCustomMessageProperties(messageHandlerMapping, filter);
     }
     else
     {
         AddMessageVersionProperty(messageType, filter);
     }
 }
Beispiel #3
0
        private CreateRuleOptions MapMessageHandlerMappingToCorrelationRuleFilter(MessageHandlerMapping messageSubscription)
        {
            var filter = new CorrelationRuleFilter
            {
                Subject = messageSubscription.SubscriptionFilter !.Label
            };

            AddMessageFilterProperties(messageSubscription, messageSubscription.MessageType, filter);

            var newRule = new CreateRuleOptions(messageSubscription.MessageType.Name, filter);

            return(newRule);
        }
Beispiel #4
0
        public void CanCreateInstanceWithCustomSubscriptionFilter()
        {
            var subscriptionFilter = new SubscriptionFilter
            {
                MessageProperties = new Dictionary <string, string>()
            };
            var messageType        = typeof(AircraftLanded);
            var messageHandlerType = typeof(AircraftLandedHandler);
            var sut = new MessageHandlerMapping(messageType, messageHandlerType, subscriptionFilter);

            Assert.Equal(messageType.FullName, sut.MessageType.FullName);
            Assert.Equal(messageHandlerType.FullName, sut.MessageHandlerType.FullName);
            Assert.Equal(subscriptionFilter, sut.SubscriptionFilter);
        }
        protected async Task AssertSubscriptionRules(MessageHandlerMapping messageHandlerMapping, string subscription)
        {
            var asyncRules = _serviceBusAdminClient.GetRulesAsync(_topic, subscription);

            var actualRules = new List <RuleProperties>();

            await foreach (var rule in asyncRules)
            {
                actualRules.Add(rule);
            }

            Assert.Single(actualRules.Where(r => r.Name == messageHandlerMapping.MessageType.Name));
            var expectedCorrelationRuleFilter = BuildCorrelationRuleFilter(messageHandlerMapping.SubscriptionFilter);
            var actualRulesForMessageType     = actualRules.Where(r => r.Name == messageHandlerMapping.MessageType.Name);

            Assert.Single(actualRulesForMessageType);
            Assert.Equal(expectedCorrelationRuleFilter, actualRulesForMessageType.First().Filter);
        }