Beispiel #1
0
        /// <summary>
        /// Add predicate-based routing rules for Scatter/Gather operations
        /// </summary>
        /// <typeparam name="TRequest"></typeparam>
        /// <typeparam name="TResponse"></typeparam>
        /// <param name="messageBus"></param>
        /// <param name="build"></param>
        /// <returns></returns>
        public static IDisposable SetupScatterRouting <TRequest, TResponse>(this IScatterGatherBus messageBus, Action <IFilterRouteBuilderSingleInput <TRequest> > build)
        {
            Assert.ArgumentNotNull(messageBus, nameof(messageBus));
            Assert.ArgumentNotNull(build, nameof(build));

            var builder = new FilterRouteBuilder <TRequest>();

            build(builder);
            var router = builder.Build();

            return(messageBus.ScatterRouter.AddScatterRouteRule <TRequest, TResponse>(builder.InTopics.FirstOrDefault(), router));
        }
Beispiel #2
0
        /// <summary>
        /// Add predicate-based routing rules for Publish operations
        /// </summary>
        /// <typeparam name="TPayload"></typeparam>
        /// <param name="messageBus"></param>
        /// <param name="build"></param>
        /// <returns></returns>
        public static IDisposable SetupPublishRouting <TPayload>(this IPubSubBus messageBus, Action <IFilterRouteBuilderMultiInput <TPayload> > build)
        {
            Assert.ArgumentNotNull(messageBus, nameof(messageBus));
            Assert.ArgumentNotNull(build, nameof(build));

            var builder = new FilterRouteBuilder <TPayload>();

            build(builder);
            var router = builder.Build();

            return(messageBus.PublishRouter.AddPublishRouteRule(builder.InTopics, router));
        }