Inheritance: IFilterCondition
Ejemplo n.º 1
0
        public static string GenerateSqlFor(AndCondition condition)
        {
            var filterExpressions = condition.Conditions.Select(ConditionSqlGenerator.GenerateSqlFor)
                                             .Select(e => $"({e})")
                                             .ToArray();

            var filterExpression = string.Join(" AND ", filterExpressions);
            return filterExpression;
        }
Ejemplo n.º 2
0
        public Task<SubscriptionClient> CreateSubscriptionReceiver(string topicPath, string subscriptionName, IFilterCondition filterCondition)
        {
            return Task.Run(() =>
            {
                EnsureSubscriptionExists(topicPath, subscriptionName);

                var myOwnSubscriptionFilterCondition = new OrCondition(new MatchCondition(MessagePropertyKeys.RedeliveryToSubscriptionName, subscriptionName),
                                                                       new IsNullCondition(MessagePropertyKeys.RedeliveryToSubscriptionName));
                var combinedCondition = new AndCondition(filterCondition, myOwnSubscriptionFilterCondition);
                var filterSql = _sqlFilterExpressionGenerator.GenerateFor(combinedCondition);

                return _retry.Do(() =>
                {
                    var subscriptionClient = _messagingFactory()
                        .CreateSubscriptionClient(topicPath, subscriptionName, ReceiveMode.ReceiveAndDelete);
                    subscriptionClient.ReplaceFilter("$Default", filterSql);
                    return subscriptionClient;
                },
                                 "Creating subscription receiver for topic " + topicPath + " and subscription " + subscriptionName + " with filter expression " +
                                 filterCondition);
            }).ConfigureAwaitFalse();
        }