Exemplo n.º 1
0
        public static EndpointConfiguration CreateCommonConfiguration(string name)
        {
            string connectionString   = @"Server=192.168.0.114;Database=ServiceControlSql;User Id=sa;Password=GQI1qNeq0oEHlL;";
            EndpointConfiguration cfg = new EndpointConfiguration(name);
            PersistenceExtensions <SqlPersistence>         persistence = cfg.UsePersistence <SqlPersistence>();
            TransportExtensions <SqlServerTransport>       transport   = cfg.UseTransport <SqlServerTransport>();
            SerializationExtensions <NewtonsoftSerializer> ser         = cfg.UseSerialization <NewtonsoftSerializer>();

            cfg.AuditSagaStateChanges(serviceControlQueue: "Particular.ServiceControl.Sql");
            cfg.AuditProcessedMessagesTo("audit");
            cfg.SendFailedMessagesTo("error");
            cfg.EnableInstallers();
            cfg.DefineCriticalErrorAction(OnCriticalError);

            persistence.SqlDialect <SqlDialect.MsSqlServer>();
            persistence.ConnectionBuilder(() => new SqlConnection(connectionString));
            persistence.SubscriptionSettings().DisableCache();

            transport.ConnectionString(connectionString);
            transport.Transactions(TransportTransactionMode.SendsAtomicWithReceive);
            transport.Routing().ApplyRouting();

            RecoverabilitySettings recoverabilityConfig = cfg.Recoverability();

            recoverabilityConfig.Immediate(delegate(ImmediateRetriesSettings config)
            {
                config.NumberOfRetries(3);
            });
            recoverabilityConfig.Delayed(delegate(DelayedRetriesSettings config)
            {
                config.NumberOfRetries(3);
            });

            return(cfg);
        }
Exemplo n.º 2
0
        public static void ConfigureForAggregates(this RecoverabilitySettings recoverability, int immediateRetries = 10, int delayedRetries = 3, bool forever = false)
        {
            var settings = recoverability.GetSettings();

            settings.Set(Defaults.SetupCorrectly, true);
            settings.Set("Retries", immediateRetries);

            // Set immediate retries to our "MaxRetries" setting
            recoverability.Immediate(x =>
            {
                x.NumberOfRetries(immediateRetries);
            });
            recoverability.Delayed(x =>
            {
                // Delayed retries don't work well with the InMemory context bag storage.  Creating
                // a problem of possible duplicate commits
                x.NumberOfRetries(0);
                //x.TimeIncrease(TimeSpan.FromSeconds(1));
                //x.NumberOfRetries(forever ? int.MaxValue : delayedRetries);
            });
        }