public PatLiteRegistry Build()
        {
            EnsureTerminatingBehavioursAdded();

            var builder        = new MessagePipelineDependencyBuilder(_messagePipelineBehaviourTypes);
            var batchBuilder   = new BatchPipelineDependencyBuilder(_batchPipelineBehaviourTypes);
            var patliteOptions = new PatLiteOptions
            {
                SubscriberConfiguration = _subscriberConfiguration,
                MessageProcessingPipelineDependencyBuilder       = builder,
                BatchMessageProcessingBehaviourDependencyBuilder = batchBuilder,
                MessageDeserialiser = _messageDeserialiser
            };

            return(new PatLiteRegistry(patliteOptions));
        }
예제 #2
0
        private PatLiteRegistry(BatchPipelineDependencyBuilder batchMessageProcessingBehaviourPipelineDependencyBuilder,
                                MessagePipelineDependencyBuilder messageProcessingPipelineDependencyBuilder)
        {
            CommonRegistrySetup();

            if (batchMessageProcessingBehaviourPipelineDependencyBuilder == null)
            {
                For <BatchProcessingBehaviourPipeline>().Use((ctx) =>
                                                             new BatchProcessingBehaviourPipeline()
                                                             .AddBehaviour <MonitoringBatchProcessingBehaviour>(ctx)
                                                             .AddBehaviour <DefaultBatchProcessingBehaviour>(ctx)
                                                             );
            }
            else
            {
                batchMessageProcessingBehaviourPipelineDependencyBuilder.RegisterTypes(this);
                For <BatchProcessingBehaviourPipeline>().Use(context => batchMessageProcessingBehaviourPipelineDependencyBuilder.Build(context));
            }

            if (messageProcessingPipelineDependencyBuilder == null)
            {
                For <MessageProcessingBehaviourPipeline>().Use((ctx) =>
                                                               new MessageProcessingBehaviourPipeline()
                                                               .AddBehaviour <DefaultMessageProcessingBehaviour>(ctx)
                                                               .AddBehaviour <MonitoringMessageProcessingBehaviour>(ctx)
                                                               .AddBehaviour <InvokeHandlerBehaviour>(ctx));

                For <DefaultMessageProcessingBehaviour>().Use <DefaultMessageProcessingBehaviour>();
                For <InvokeHandlerBehaviour>().Use <InvokeHandlerBehaviour>();
            }
            else
            {
                messageProcessingPipelineDependencyBuilder.RegisterTypes(this);
                For <MessageProcessingBehaviourPipeline>().Use(context => messageProcessingPipelineDependencyBuilder.Build(context));
            }

            For <IMultipleBatchProcessor>().Use <MultipleBatchProcessor>().Ctor <string>().Is(context => context.GetInstance <SubscriberConfiguration>().SubscriberName);
            For <BatchProcessor>().Use <BatchProcessor>();
            For <BatchFactory>().Use <BatchFactory>();
            For <IMessageReceiverFactory>().Use <AzureServiceBusMessageReceiverFactory>();
            For <ISubscriptionBuilder>().Use <SubscriptionBuilder>();
            For <BatchConfiguration>().Use(context => new BatchConfiguration(
                                               context.GetInstance <SubscriberConfiguration>().BatchSize,
                                               context.GetInstance <SubscriberConfiguration>().ReceiveTimeoutSeconds));
        }