/// <summary> /// Called once when the worker role is started in Azure. /// </summary> /// <returns><c>true</c> if the role should continue to run, <c>false</c> otherwise.</returns> /// <remarks> /// <para> /// If the OnStart method returns false, the role instance is immediately stopped. If the method returns true, /// Windows Azure starts the role by calling the Run method. /// </para> /// </remarks> public override bool OnStart() { // Set the maximum number of concurrent connections ServicePointManager.DefaultConnectionLimit = 12; // For information on handling configuration changes // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357. using (var config = new SystemConfigurationSource()) { var settings = RetryPolicyConfigurationSettings.GetRetryPolicySettings(config); // Initialize the RetryPolicyFactory with a RetryManager built from the // settings in the configuration file. RetryPolicyFactory.SetRetryManager(settings.BuildRetryManager()); } // set up a logger _log = new Lazy <ILog>(() => LogManager.GetLogger("default")); // create a unique process id for this worker. This is passed to the CopyTenant method on the // and table driver to allow for process specific functionality _uniqueProcessID = Guid.NewGuid(); return(base.OnStart()); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var settings = RetryPolicyConfigurationSettings.GetRetryPolicySettings(new SystemConfigurationSource()); RetryPolicyFactory.SetRetryManager(settings.BuildRetryManager()); Application.Run(new Main()); }
private static void SetUpRetryPolicy() { using (var config = new SystemConfigurationSource()) { var settings = RetryPolicyConfigurationSettings.GetRetryPolicySettings(config); // Initialize the RetryPolicyFactory with a RetryManager built from the // settings in the configuration file. var buildRetryManager = settings.BuildRetryManager(); RetryPolicyFactory.SetRetryManager(buildRetryManager); } }
public void Cleanup() { RetryPolicyFactory.SetRetryManager(null, false); // Work around, close the connection manually. if (this.connection?.State == ConnectionState.Open) { this.connection.Close(); } this.connection?.Dispose(); }
public void Cleanup() { RetryPolicyFactory.SetRetryManager(null, false); if (connection != null) { // Work around, close the connection manually. if (connection.State == ConnectionState.Open) { connection.Close(); } connection.Dispose(); } }
public static void Configure(IUnityContainer container) { // Get Entlib config source (Current is in Web.EnterpriseLibrary.config) IConfigurationSource source = ConfigurationSourceFactory.Create(); // Config container from Policy injection config settings var policyInjectionSettings = (PolicyInjectionSettings)source.GetSection(PolicyInjectionSettings.SectionName); policyInjectionSettings.ConfigureContainer(container); // Config retry policy var retryPolicySettings = RetryPolicyConfigurationSettings.GetRetryPolicySettings(source); // turn off throwIfSet for unit testing RetryPolicyFactory.SetRetryManager(retryPolicySettings.BuildRetryManager(), throwIfSet: false); // get factories from config var policyFactory = new ExceptionPolicyFactory(source); var dbFactory = new DatabaseProviderFactory(source); var validationFactory = ConfigurationValidatorFactory.FromConfigurationSource(source); // Set default locator UnityServiceLocator locator = new UnityServiceLocator(container); ServiceLocator.SetLocatorProvider(() => locator); container .AddNewExtension <Interception>() // register Entlib types with appropiate factory .RegisterType <ExceptionManager>(new InjectionFactory(c => policyFactory.CreateManager())) .RegisterType <Database>(new InjectionFactory(c => dbFactory.CreateDefault())) .RegisterInstance <ValidatorFactory>(validationFactory) // use registration by convention extension for registering app types; IProfileStore, IUserRepository .RegisterTypes(AllClasses.FromAssemblies(Assembly.GetExecutingAssembly()), WithMappings.FromAllInterfacesInSameAssembly, WithName.Default, WithLifetime.ContainerControlled) // register types with interception .RegisterType <AExpense.Model.User>(new Interceptor <VirtualMethodInterceptor>(), new InterceptionBehavior <TracingBehavior>()) .RegisterType <IExpenseRepository, ExpenseRepository>(new Interceptor <VirtualMethodInterceptor>(), new InterceptionBehavior <PolicyInjectionBehavior>()); }
protected override void Teardown() { RetryPolicyFactory.SetRetryManager(null, false); }
protected override void Arrange() { RetryPolicyFactory.SetRetryManager(GetSettings().BuildRetryManager(), false); }
public void Cleanup() { RetryPolicyFactory.SetRetryManager(null, false); }
public void Initialize() { RetryPolicyFactory.SetRetryManager(RetryConfiguration.GetRetryManager(getCustomRetryStrategy: section => section.Get <TestRetryStrategyOptions>().ToTestRetryStrategy(section.Key)), false); }