Last active
December 23, 2015 10:30
-
-
Save ramonsmits/f590c83b92056dcdf3b6 to your computer and use it in GitHub Desktop.
NServiceBus Host EndpointConfiguration initializing Log4net xml configuration, app domain diagnostic events and using Profile to target NHibernate persistence
This file contains 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
using System; | |
using NServiceBus; | |
using NServiceBus.Hosting.Profiles; | |
using NServiceBus.Log4Net; | |
using NServiceBus.Logging; | |
public class EndpointConfig : IConfigureThisEndpoint | |
{ | |
public EndpointConfig() | |
{ | |
log4net.Config.XmlConfigurator.Configure(); | |
LogManager.Use<Log4NetFactory>(); | |
var appDomainLogger = LogManager.GetLogger("AppDomain"); | |
AppDomain.CurrentDomain.FirstChanceException += (o, ea) => { appDomainLogger.Debug("FirstChanceException", ea.Exception); }; | |
AppDomain.CurrentDomain.UnhandledException += (o, ea) => { appDomainLogger.Debug("UnhandledException", ea.ExceptionObject as Exception); }; | |
} | |
void IConfigureThisEndpoint.Customize(BusConfiguration busConfiguration) | |
{ | |
busConfiguration.EndpointName("Samples.NServiceBus.Host"); | |
busConfiguration.UseSerialization<JsonSerializer>(); | |
busConfiguration.UsePersistence<InMemoryPersistence>(); | |
} | |
} | |
namespace Test | |
{ | |
public class ProductionHandler : IHandleProfile<Test.Production> | |
{ | |
public void ProfileActivated(BusConfiguration busConfiguration) | |
{ | |
log4net.LogManager.GetLogger(typeof(ProductionHandler)).Fatal("ProfileActivated"); | |
busConfiguration.UsePersistence<NHibernatePersistence>(); | |
busConfiguration.EnableInstallers(); | |
} | |
} | |
public class Production : NServiceBus.Production | |
{ | |
} | |
} |
shamglam
commented
Dec 23, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment