diff --git a/src/Umbraco.Web/BatchedDatabaseServerMessenger.cs b/src/Umbraco.Web/BatchedDatabaseServerMessenger.cs index 4eeb5c84f9..fee56fd209 100644 --- a/src/Umbraco.Web/BatchedDatabaseServerMessenger.cs +++ b/src/Umbraco.Web/BatchedDatabaseServerMessenger.cs @@ -18,31 +18,45 @@ namespace Umbraco.Web /// /// This binds to appropriate umbraco events in order to trigger the Boot(), Sync() & FlushBatch() calls /// - public class BatchedDatabaseServerMessenger : Core.Sync.DatabaseServerMessenger + public class BatchedDatabaseServerMessenger : DatabaseServerMessenger, IApplicationEventHandler { public BatchedDatabaseServerMessenger(ApplicationContext appContext, bool enableDistCalls, DatabaseServerMessengerOptions options) : base(appContext, enableDistCalls, options) - { - UmbracoApplicationBase.ApplicationStarted += Application_Started; - UmbracoModule.EndRequest += UmbracoModule_EndRequest; - UmbracoModule.RouteAttempt += UmbracoModule_RouteAttempt; + { } - private void Application_Started(object sender, EventArgs eventArgs) - { - if (ApplicationContext.IsConfigured == false - || ApplicationContext.DatabaseContext.IsDatabaseConfigured == false - || ApplicationContext.DatabaseContext.CanConnect == false) - { + #region Application Event Handler implementation - LogHelper.Warn("The app is not configured or cannot connect to the database, this server cannot be initialized with " - + typeof (BatchedDatabaseServerMessenger) + ", distributed calls will not be enabled for this server"); + public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) + { + } + + public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) + { + } + + /// + /// Bootup is completed, this will not execute if the application is not configured + /// + /// + /// + public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) + { + UmbracoModule.EndRequest += UmbracoModule_EndRequest; + UmbracoModule.RouteAttempt += UmbracoModule_RouteAttempt; + + if (applicationContext.DatabaseContext.IsDatabaseConfigured == false || applicationContext.DatabaseContext.CanConnect == false) + { + applicationContext.ProfilingLogger.Logger.Warn( + "The app cannot connect to the database, this server cannot be initialized with " + + typeof(BatchedDatabaseServerMessenger) + ", distributed calls will not be enabled for this server"); } else { - Boot(); + Boot(); } } + #endregion private void UmbracoModule_RouteAttempt(object sender, RoutableAttemptEventArgs e) { @@ -137,5 +151,7 @@ namespace Umbraco.Web batch.Add(new RefreshInstructionEnvelope(servers, refresher, RefreshInstruction.GetInstructions(refresher, messageType, ids, idType, json))); } + + } } \ No newline at end of file