Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 6
0
 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);
     }
 }
Ejemplo n.º 7
0
 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>();
 }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        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);
            }
        }
Ejemplo n.º 10
0
 public BusReceiver(IUnityContainer container, MessageHandlerRegistry handlerRegistry)
 {
     this.container = container;
     this.handlerRegistry = handlerRegistry;
     this.logBuffer = LogBuffer.Current;
 }
Ejemplo n.º 11
0
 private void RunServiceBusSelfTest(LogBuffer logBuffer)
 {
     var bus = PlatformApplication.Current.Container.Resolve<IBus>();
     BusSelfTest.Run(bus, logBuffer);
 }
Ejemplo n.º 12
0
 /// <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.
 }
Ejemplo n.º 15
0
        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;
        }
Ejemplo n.º 16
0
 private void WriteToLog(LogBuffer logBuffer)
 {
     logBuffer.FlushToLog("Request log", LogPriority.Request);
 }
Ejemplo n.º 17
0
 void IServiceBusAreaRegistration.ConfigureContainer(
     IUnityContainer container,
     LogBuffer logBuffer)
 {
     this.ConfigureContainerIfNecessary(container, logBuffer);
 }
Ejemplo n.º 18
0
 private void RegisterPlatformAreas(IUnityContainer container, LogBuffer logBuffer)
 {
     var state = new PlatformAreaRegistrationState(container, logBuffer);
     AreaRegistration.RegisterAllAreas(state);
 }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 21
0
 private void CreateEndpoints(LogBuffer logBuffer)
 {
     new BusReceiverEndpointCreator().CreateEndpoints(this, logBuffer);
     BusReceiverDataContractResolver.AddToEndpoints(this.Description.Endpoints);
 }