protected override void ConfigureContainer(IUnityContainer container, LogBuffer log)
 {
     BrnklyDocumentStore.Register(
         container,
         StoreName.Content,
         StoreAccessMode.ReadWrite);
 }
 private void LogCreatingEndpoint(BusEndpointInfo endpointInfo, LogBuffer logBuffer)
 {
     logBuffer.Information(
         "Creating service endpoint:\n\tAddress: {0}\n\tQueue name:{1}",
         endpointInfo.LocalhostUri,
         endpointInfo.QueueName);
 }
        private void LogAssembliesLoaded(LogBuffer logBuffer)
        {
            string assembliesLoaded =
                string.Join(
                    "\n",
                    BuildManager.GetReferencedAssemblies()
                        .Cast<Assembly>()
                        .OrderBy(a => a.FullName)
                        .Select(a => a.FullName));

            logBuffer.Information("Assemblies loaded:\n{0}", assembliesLoaded);
        }
        public virtual void CreateEndpoints(ServiceHost serviceHost, LogBuffer logBuffer)
        {
            string applicationName = this.GetApplicationName(serviceHost);

            var applicationEndpoints = new ApplicationEndpoints(applicationName, Environment.MachineName);
            foreach (var endpointInfo in applicationEndpoints)
            {
                this.LogCreatingEndpoint(endpointInfo, logBuffer);
                this.ValidateThatQueueExists(endpointInfo.QueueName);
                this.AddServiceEndpoint(serviceHost, endpointInfo);
            }
        }
        private void host_Faulted(object sender, EventArgs e)
        {
            var logBuffer = new LogBuffer();

            try
            {
                logBuffer.Critical("The BusReceiverServiceHost faulted. Attempting to re-open...");

                this.serviceHost.Abort();
                this.serviceHost = this.CreateServiceHostInternal();
                this.serviceHost.Open();

                logBuffer.Information("BusReceiverServiceHost re-opened.");
            }
            finally
            {
                logBuffer.FlushToLog(LogPriority.Application, LogCategory.ServiceBus);
            }
        }
 public static void LoadRavenConfig(IDocumentStore operationsStore, LogBuffer logBuffer)
 {
     try
     {
         using (var session = operationsStore.OpenSession())
         {
             var config = session.Load<RavenConfig>(RavenConfig.StorageId);
             BrnklyDocumentStore.UpdateAllStores(config);
         }
     }
     catch (Exception exception)
     {
         logBuffer.Critical(
             "Failed to load the Raven configuration due to the exception below. " +
             "The application may not function correctly until a valid Raven configuration is received.");
         logBuffer.Critical(exception);
     }
 }
 private void InitializeServiceBus(LogBuffer logBuffer)
 {
     logBuffer.Information("Configuring service bus.");
     Bus.FactoryMethod = provider => new WcfBusImplementation(provider, true);
     Bus.UpdateSubscriptions(
         new EnvironmentConfig()
             .WithDefaultsForEnvironmentType(this.EnvironmentType)
             .ExpandMachineGroups()
             .Applications);
     this.Container.RegisterInstance<IBus>(new Bus());
     MessageHandlerRegistry.RegisterAllHandlerTypes();
     this.Container.RegisterInstance<MessageHandlerRegistry>(MessageHandlerRegistry.Instance);
     this.Container.RegisterType<IBusReceiver, BusReceiver>();
 }
        private void InitializeOperationsStoreAndDocs(LogBuffer logBuffer)
        {
            logBuffer.Information("Registering Operations store.");
            var operationsStore =
                BrnklyDocumentStore.Register(this.Container, StoreName.Operations);

            LoadRavenConfig(operationsStore, logBuffer);

            this.Container.Resolve<EnvironmentConfigUpdater>()
                .Initialize(EnvironmentConfig.StorageId, logBuffer);

            this.Container.Resolve<LoggingSettingsUpdater>()
                .Initialize(LoggingSettings.StorageId, logBuffer);

            this.Container.Resolve<CacheSettingsUpdater>()
                .Initialize(CacheSettingsData.StorageId, logBuffer);
        }
        private void AllowAreasToConfigureContainer(LogBuffer logBuffer)
        {
            var areaTypes = AssemblyHelper
                .GetConstructableTypes<IServiceBusAreaRegistration>();

            foreach (var areaType in areaTypes)
            {
                var areaInstance =
                    (IServiceBusAreaRegistration)Activator.CreateInstance(areaType);
                areaInstance.ConfigureContainer(this.Container, logBuffer);
            }
        }
Example #10
0
 public BusReceiver(IUnityContainer container, MessageHandlerRegistry handlerRegistry)
 {
     this.container = container;
     this.handlerRegistry = handlerRegistry;
     this.logBuffer = LogBuffer.Current;
 }
 private void RunServiceBusSelfTest(LogBuffer logBuffer)
 {
     var bus = PlatformApplication.Current.Container.Resolve<IBus>();
     BusSelfTest.Run(bus, logBuffer);
 }
 /// <summary>
 /// Configures the dependency injection container and performs other one-time startup actions.
 /// Place calls to BrnklyDocumentStore.Register() in this method.
 /// Guaranteed to execute exactly once, before the first web request or service bus message is handled.
 /// </summary>
 /// <param name="container">An IUnityContainer instance.</param>
 protected abstract void ConfigureContainer(IUnityContainer container, LogBuffer log);
 public PlatformAreaRegistrationState(IUnityContainer container, LogBuffer logBuffer)
 {
     this.Container = container;
     this.Log = logBuffer;
 }
 protected override void ConfigureContainer(IUnityContainer container, LogBuffer log)
 {
     // Do nothing.
 }
        private void ConfigureContainerIfNecessary(
            IUnityContainer container,
            LogBuffer logBuffer)
        {
            if (!areasWithContainerConfigured.TryAdd(this.GetType(), false))
            {
                logBuffer.Information(
                    "Container has already been configured for area {0}.",
                    this.AreaName);
                return;
            }

            logBuffer.Information("Configuring container for area {0}.", this.AreaName);
            this.ConfigureContainer(container, logBuffer);
            areasWithContainerConfigured[this.GetType()] = true;
        }
Example #16
0
 private void WriteToLog(LogBuffer logBuffer)
 {
     logBuffer.FlushToLog("Request log", LogPriority.Request);
 }
 void IServiceBusAreaRegistration.ConfigureContainer(
     IUnityContainer container,
     LogBuffer logBuffer)
 {
     this.ConfigureContainerIfNecessary(container, logBuffer);
 }
 private void RegisterPlatformAreas(IUnityContainer container, LogBuffer logBuffer)
 {
     var state = new PlatformAreaRegistrationState(container, logBuffer);
     AreaRegistration.RegisterAllAreas(state);
 }
Example #19
0
        internal PlatformApplication Initialize(LogBuffer logBuffer)
        {
            lock (this.configurationLock)
            {
                if (this.isConfigured)
                {
                    return this;
                }

                try
                {
                    logBuffer.Information("Configuring PlatformApplication...");

                    this.Container = new UnityContainer();
                    this.InitializeServiceBus(logBuffer);
                    this.InitializeOperationsStoreAndDocs(logBuffer);
                    this.AllowAreasToConfigureContainer(logBuffer);
                    isConfigured = true;

                    logBuffer.Information("PlatformApplication was successfully configured.");
                }
                catch (Exception exception)
                {
                    logBuffer.Critical("PlatformApplication configuration failed due to the exception below.");
                    logBuffer.Critical(exception);
                    throw;
                }

                return this;
            }
        }
Example #20
0
        private static bool TryGetFromHttpContext(out LogBuffer logBuffer)
        {
            if (HttpContext.Current == null)
            {
                logBuffer = null;
                return false;
            }

            logBuffer = HttpContext.Current.GetOrCreateItem<LogBuffer>(
                typeof(LogBuffer).FullName);
            return true;
        }
 private void CreateEndpoints(LogBuffer logBuffer)
 {
     new BusReceiverEndpointCreator().CreateEndpoints(this, logBuffer);
     BusReceiverDataContractResolver.AddToEndpoints(this.Description.Endpoints);
 }