public override async Task Initialize(AspNetCoreConfiguration platibusConfiguration, string configSectionName = null)
        {
            var diagnosticService = platibusConfiguration.DiagnosticService;

            if (string.IsNullOrWhiteSpace(configSectionName))
            {
                configSectionName = "platibus";
                await diagnosticService.EmitAsync(
                    new DiagnosticEventBuilder(this, DiagnosticEventType.ConfigurationDefault)
                {
                    Detail = $"Using default configuration section \"{configSectionName}\""
                }.Build());
            }

            var configSection = LoadConfigurationSection(configSectionName, diagnosticService);

            await Initialize(platibusConfiguration, configSection);

            platibusConfiguration.BaseUri = configSection?.GetValue <Uri>("baseUri");
            platibusConfiguration.BypassTransportLocalDestination = configSection?.GetValue("BypassTransportLocalDestination", true) ?? true;

            var mqsFactory = new MessageQueueingServiceFactory(platibusConfiguration.DiagnosticService);
            var mqsConfig  = configSection?.GetSection("queueing");

            platibusConfiguration.MessageQueueingService = await mqsFactory.InitMessageQueueingService(mqsConfig);

            var stsFactory = new SubscriptionTrackingServiceFactory(platibusConfiguration.DiagnosticService);
            var stsConfig  = configSection?.GetSection("subscriptionTracking");

            platibusConfiguration.SubscriptionTrackingService = await stsFactory.InitSubscriptionTrackingService(stsConfig);
        }
Ejemplo n.º 2
0
        public override async Task Initialize(LoopbackConfiguration platibusConfiguration, IConfiguration configuration)
        {
            if (platibusConfiguration == null)
            {
                throw new ArgumentNullException(nameof(platibusConfiguration));
            }

            await InitializeDiagnostics(platibusConfiguration, configuration);

            var diagnosticService = platibusConfiguration.DiagnosticService;

            platibusConfiguration.ReplyTimeout         = configuration?.GetValue <TimeSpan>("replyTimeout") ?? TimeSpan.Zero;
            platibusConfiguration.SerializationService = new DefaultSerializationService();
            platibusConfiguration.MessageNamingService = new DefaultMessageNamingService();
            platibusConfiguration.DefaultContentType   = configuration?["defaultContentType"];

            InitializeDefaultSendOptions(platibusConfiguration, configuration);
            InitializeTopics(platibusConfiguration, configuration);

            var messageJournalFactory = new MessageJournalFactory(diagnosticService);
            var journalingSection     = configuration?.GetSection("journaling");

            platibusConfiguration.MessageJournal = await messageJournalFactory.InitMessageJournal(journalingSection);

            var mqsFactory      = new MessageQueueingServiceFactory(platibusConfiguration.DiagnosticService);
            var queueingSection = configuration?.GetSection("queueing");

            platibusConfiguration.MessageQueueingService = await mqsFactory.InitMessageQueueingService(queueingSection);
        }
        /// <summary>
        /// Initializes the supplied HTTP server <paramref name="configuration"/> based on the
        /// properties of the provided <paramref name="configSection"/>
        /// </summary>
        /// <param name="configuration">The configuration to initialize</param>
        /// <param name="configSection">The configuration section whose properties are to be used
        /// to initialize the <paramref name="configuration"/></param>
        /// <returns>Returns a task that completes when the configuration has been initialized</returns>
        public async Task Initialize(OwinConfiguration configuration, OwinConfigurationSection configSection)
        {
            await base.Initialize(configuration, configSection);

            configuration.BaseUri = configSection.BaseUri;
            configuration.BypassTransportLocalDestination = configSection.BypassTransportLocalDestination;

            var mqsFactory = new MessageQueueingServiceFactory(configuration.DiagnosticService);
            var mqsConfig  = configSection.Queueing;

            configuration.MessageQueueingService = await mqsFactory.InitMessageQueueingService(mqsConfig);

            var stsFactory = new SubscriptionTrackingServiceFactory(configuration.DiagnosticService);
            var stsConfig  = configSection.SubscriptionTracking;

            configuration.SubscriptionTrackingService = await stsFactory.InitSubscriptionTrackingService(stsConfig);
        }
        /// <inheritdoc />
        /// <summary>
        /// Initializes the supplied HTTP server <paramref name="platibusConfiguration" /> based on the
        /// properties of the provided <paramref name="configuration" />
        /// </summary>
        /// <param name="platibusConfiguration">The configuration to initialize</param>
        /// <param name="configuration">The configuration section whose properties are to be used
        /// to initialize the <paramref name="platibusConfiguration" /></param>
        /// <returns>Returns a task that completes when the configuration has been initialized</returns>
        public override async Task Initialize(HttpServerConfiguration platibusConfiguration, IConfiguration configuration)
        {
            await base.Initialize(platibusConfiguration, configuration);

            platibusConfiguration.BaseUri          = configuration?.GetValue <Uri>("baseUri");
            platibusConfiguration.ConcurrencyLimit = configuration?.GetValue("concurrencyLimit", 0) ?? 0;

            InitializeAuthenticationSchemes(platibusConfiguration, configuration);
            platibusConfiguration.BypassTransportLocalDestination = configuration?.GetValue <bool>("bypassTransportLocalDestination") ?? false;

            var mqsFactory      = new MessageQueueingServiceFactory(platibusConfiguration.DiagnosticService);
            var queueingSection = configuration?.GetSection("queueing");

            platibusConfiguration.MessageQueueingService = await mqsFactory.InitMessageQueueingService(queueingSection);

            var stsFactory = new SubscriptionTrackingServiceFactory(platibusConfiguration.DiagnosticService);
            var stSection  = configuration?.GetSection("subscriptionTracking");

            platibusConfiguration.SubscriptionTrackingService = await stsFactory.InitSubscriptionTrackingService(stSection);
        }
        /// <summary>
        /// Initializes the supplied HTTP server <paramref name="platibusConfiguration"/> based on the
        /// properties of the provided <paramref name="configSection"/>
        /// </summary>
        /// <param name="platibusConfiguration">The configuration to initialize</param>
        /// <param name="configSection">The configuration section whose properties are to be used
        /// to initialize the <paramref name="platibusConfiguration"/></param>
        /// <returns>Returns a task that completes when the configuration has been initialized</returns>
        public async Task Initialize(HttpServerConfiguration platibusConfiguration,
                                     HttpServerConfigurationSection configSection)
        {
            await base.Initialize(platibusConfiguration, configSection);

            platibusConfiguration.BaseUri                         = configSection.BaseUri;
            platibusConfiguration.ConcurrencyLimit                = configSection.ConcurrencyLimit;
            platibusConfiguration.AuthenticationSchemes           = configSection.AuthenticationSchemes.GetFlags();
            platibusConfiguration.BypassTransportLocalDestination = configSection.BypassTransportLocalDestination;

            var mqsFactory = new MessageQueueingServiceFactory(platibusConfiguration.DiagnosticService);
            var mqsConfig  = configSection.Queueing;

            platibusConfiguration.MessageQueueingService = await mqsFactory.InitMessageQueueingService(mqsConfig);

            var stsFactory = new SubscriptionTrackingServiceFactory(platibusConfiguration.DiagnosticService);
            var stsConfig  = configSection.SubscriptionTracking;

            platibusConfiguration.SubscriptionTrackingService =
                await stsFactory.InitSubscriptionTrackingService(stsConfig);
        }
        /// <summary>
        /// Initializes the specified <paramref name="platibusConfiguration"/> object according to the
        /// values in the supplied loopback <paramref name="configSection"/>
        /// </summary>
        /// <param name="platibusConfiguration">The configuration object to initialize</param>
        /// <param name="configSection">The <see cref="LoopbackConfigurationSection"/>
        /// containing the values used to initialize the Platibus configuration</param>
        public async Task Initialize(LoopbackConfiguration platibusConfiguration, LoopbackConfigurationSection configSection)
        {
            if (platibusConfiguration == null)
            {
                throw new ArgumentNullException(nameof(platibusConfiguration));
            }
            if (configSection == null)
            {
                throw new ArgumentNullException(nameof(configSection));
            }

            await InitializeDiagnostics(platibusConfiguration, configSection);

            platibusConfiguration.ReplyTimeout         = configSection.ReplyTimeout;
            platibusConfiguration.SerializationService = new DefaultSerializationService();
            platibusConfiguration.MessageNamingService = new DefaultMessageNamingService();
            platibusConfiguration.DefaultContentType   = configSection.DefaultContentType;

            if (configSection.DefaultSendOptions != null)
            {
                platibusConfiguration.DefaultSendOptions = new SendOptions
                {
                    ContentType = configSection.DefaultSendOptions.ContentType,
                    TTL         = configSection.DefaultSendOptions.TTL,
                    Synchronous = configSection.DefaultSendOptions.Synchronous
                };
            }

            InitializeTopics(platibusConfiguration, configSection);

            var messageJournalFactory = new MessageJournalFactory(platibusConfiguration.DiagnosticService);

            platibusConfiguration.MessageJournal = await messageJournalFactory.InitMessageJournal(configSection.Journaling);

            var mqsFactory = new MessageQueueingServiceFactory(platibusConfiguration.DiagnosticService);

            platibusConfiguration.MessageQueueingService = await mqsFactory.InitMessageQueueingService(configSection.Queueing);
        }
        public static Task <IMessageQueueingService> InitMessageQueueingService(QueueingElement config)
        {
            var factory = new MessageQueueingServiceFactory();

            return(factory.InitMessageQueueingService(config));
        }