Created
June 11, 2015 14:57
-
-
Save Shazwazza/6d75bca3f98d7ef98378 to your computer and use it in GitHub Desktop.
Umbraco 7.3 - Enable DatabaseServerMessenger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoadBalancingConfigurationEventHandler : ApplicationEventHandler | |
{ | |
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) | |
{ | |
//Replace the server messenger: | |
ServerMessengerResolver.Current.SetServerMessenger(new BatchedDatabaseServerMessenger( | |
applicationContext, | |
true, | |
//You can customize some options by setting the options parameters here: | |
new DatabaseServerMessengerOptions | |
{ | |
//These callbacks will be executed if the server has not been synced | |
// (i.e. it is a new server or the lastsynced.txt file has been removed) | |
InitializingCallbacks = new Action[] | |
{ | |
//rebuild the xml cache file if the server is not synced | |
() => global::umbraco.content.Instance.RefreshContentFromDatabase(), | |
//rebuild indexes if the server is not synced | |
// NOTE: This will rebuild ALL indexes including the members, if developers want to target specific | |
// indexes then they can adjust this logic themselves. | |
() => Examine.ExamineManager.Instance.RebuildIndex() | |
} | |
})); | |
//Replace the server registrar (this is optional but allows you to track active servers participating | |
// in your load balanced environment): | |
ServerRegistrarResolver.Current.SetServerRegistrar(new DatabaseServerRegistrar( | |
new Lazy<ServerRegistrationService>(() => applicationContext.Services.ServerRegistrationService), | |
//You can customize some options by setting the options parameters here: | |
new DatabaseServerRegistrarOptions())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment