Beispiel #1
0
        public static EndpointConfiguration GetSqlConfiguration(string name, out TransportExtensions <SqlServerTransport> transport)
        {
            const string connectionString      = "Data Source=localhost;Initial Catalog=Messages;User ID=messages_user;Password=password123";
            var          endpointConfiguration = new EndpointConfiguration(name);

            endpointConfiguration.EnableInstallers();
            endpointConfiguration.DisableFeature <TimeoutManager>();
            var persistence = endpointConfiguration.UsePersistence <SqlPersistence>();

            persistence.SqlDialect <SqlDialect.MsSqlServer>();
            persistence.ConnectionBuilder(
                connectionBuilder: () =>
            {
                return(new SqlConnection(connectionString));
            });
            var subscriptions = persistence.SubscriptionSettings();

            subscriptions.CacheFor(TimeSpan.FromMinutes(5));

            transport = endpointConfiguration.UseTransport <SqlServerTransport>();
            transport.ConnectionString(connectionString);
            transport.Transactions(TransportTransactionMode.None);

            return(endpointConfiguration);
        }
Beispiel #2
0
        public static void ConfigureTransport(this TransportExtensions <AzureServiceBusTransport> transport, TransportSettings transportSettings, TransportTransactionMode transportTransactionMode)
        {
            transport.ConfigureNameShorteners();

            transport.Transactions(transportTransactionMode);
            transport.ConnectionString(transportSettings.ConnectionString);
        }
        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);
        }
Beispiel #4
0
 void ProvideConfiguration(TransportExtensions <LearningTransport> transport)
 {
     #region 6to7ConnectionStrings
     var connectionString = ConfigurationManager.ConnectionStrings["theConnectionName"].ConnectionString;
     transport.ConnectionString(connectionString);
     #endregion
 }
        static void ConfigureConnection(TransportExtensions <SqlServerTransport> transport, TransportSettings transportSettings)
        {
            var connectionString = transportSettings.ConnectionString
                                   .RemoveCustomConnectionStringParts(out var customSchema, out var subscriptionsTableSetting);

            var subscriptions = transport.SubscriptionSettings();

            if (customSchema != null)
            {
                transport.DefaultSchema(customSchema);
                subscriptions.SubscriptionTableName(defaultSubscriptionTableName, customSchema);
            }

            if (subscriptionsTableSetting != null)
            {
                var subscriptionsAddress = QueueAddress.Parse(subscriptionsTableSetting);

                subscriptions.SubscriptionTableName(
                    tableName: subscriptionsAddress.Table,
                    schemaName: subscriptionsAddress.Schema ?? customSchema,
                    catalogName: subscriptionsAddress.Catalog
                    );
            }

            transport.ConnectionString(connectionString);

            transport.EnableMessageDrivenPubSubCompatibilityMode();
        }
Beispiel #6
0
        static void ConfigureTransport(TransportExtensions <AzureStorageQueueTransport> transport, TransportSettings transportSettings)
        {
            transport.SanitizeQueueNamesWith(BackwardsCompatibleQueueNameSanitizer.Sanitize);
            transport.Transactions(TransportTransactionMode.ReceiveOnly);
            transport.ConnectionString(transportSettings.ConnectionString);

            transport.MessageInvisibleTime(TimeSpan.FromMinutes(1));
        }
            protected override void Setup(TransportExtensions <AzureStorageQueueTransport> cfg)
            {
                cfg.ConnectionString(defaultConnectionString);

                cfg.UseAccountAliasesInsteadOfConnectionStrings()
                .DefaultAccountAlias(DefaultConnectionStringName)
                .AccountRouting()
                .AddAccount(AnotherConnectionStringName, anotherConnectionString);
            }
Beispiel #8
0
        public static void ConfigureTransport(this EndpointConfiguration endpointCfg, string connectionString)
        {
            endpointCfg.EnableInstallers();

            TransportExtensions <AzureServiceBusTransport> transport = endpointCfg.UseTransport <AzureServiceBusTransport>();

            transport.ConnectionString(connectionString);

            //endpointCfg.UseTransport<LearningTransport>();
        }
Beispiel #9
0
        public static void ConfigureTransport(this TransportExtensions <AzureServiceBusTransport> transport, TransportSettings transportSettings)
        {
            transport.Transactions(TransportTransactionMode.SendsAtomicWithReceive);
            transport.ConnectionString(transportSettings.ConnectionString);

            transport.MessageReceivers().PrefetchCount(0);
            transport.Queues().LockDuration(TimeSpan.FromMinutes(5));
            transport.Subscriptions().LockDuration(TimeSpan.FromMinutes(5));
            transport.MessagingFactories().NumberOfMessagingFactoriesPerNamespace(2);
            transport.NumberOfClientsPerEntity(Math.Min(Environment.ProcessorCount, transportSettings.MaxConcurrency));
        }
Beispiel #10
0
    public static void ConfigureASB(this TransportExtensions <AzureServiceBusTransport> extensions)
    {
        var connectionString = EnvironmentHelper.GetEnvironmentVariable("AzureServiceBus.ConnectionString");

        extensions.ConnectionString(connectionString);


        var settings   = extensions.GetSettings();
        var serializer = Tuple.Create(new FakeSerializer() as SerializationDefinition, new SettingsHolder());

        settings.Set("MainSerializer", serializer);
    }
Beispiel #11
0
#pragma warning disable 618
        public static void ConfigureTransport(this TransportExtensions <AzureServiceBusTransport> transport, TransportSettings transportSettings, TransportTransactionMode transactionMode)
#pragma warning restore 618
        {
            //If the custom part stays in the connection string and is at the end, the sdk will treat is as part of the SharedAccessKey
            var connectionString = ConnectionStringPartRemover.Remove(transportSettings.ConnectionString, QueueLengthProvider.QueueLengthQueryIntervalPartName);

            transport.ConnectionString(connectionString);
            transport.Transactions(transactionMode);
            transport.Queues().LockDuration(TimeSpan.FromMinutes(5));
            transport.Subscriptions().LockDuration(TimeSpan.FromMinutes(5));
            transport.MessagingFactories().NumberOfMessagingFactoriesPerNamespace(2);
            transport.NumberOfClientsPerEntity(Math.Min(Environment.ProcessorCount, transportSettings.MaxConcurrency));
        }
Beispiel #12
0
        static void ConfigureConnection(TransportExtensions <SqlServerTransport> transport, TransportSettings transportSettings)
        {
            var builder = new DbConnectionStringBuilder
            {
                ConnectionString = transportSettings.ConnectionString
            };

            if (builder.TryGetValue(queueSchemaName, out var customSchema))
            {
                builder.Remove(queueSchemaName);

                transport.DefaultSchema((string)customSchema);
            }

            transport.ConnectionString(builder.ConnectionString);
        }
Beispiel #13
0
    public static void ConfigureASQ(this TransportExtensions <AzureStorageQueueTransport> extensions)
    {
        var connectionString = EnvironmentHelper.GetEnvironmentVariable("AzureStorageQueues.ConnectionString");

        extensions.ConnectionString(connectionString);

        var settings   = extensions.GetSettings();
        var serializer = Tuple.Create(new NewtonsoftSerializer() as SerializationDefinition, new SettingsHolder());

        settings.Set("MainSerializer", serializer);

        bool isMessageType(Type t) => t == typeof(MessageWrapper);

        var ctor = typeof(MessageMetadataRegistry).GetConstructor(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new[] { typeof(Func <Type, bool>) }, null);

        settings.Set <MessageMetadataRegistry>(ctor.Invoke(new object[] { (Func <Type, bool>)isMessageType }));
    }
Beispiel #14
0
        public EndpointConfigurationBuilder(string endpointName, string transportConnectionString)
        {
            _endpointConfiguration = new EndpointConfiguration(endpointName);

            // setup general
            _endpointConfiguration.UseSerialization <NewtonsoftSerializer>();
            _endpointConfiguration.EnableInstallers();

            // setup auditing
            _endpointConfiguration.SendFailedMessagesTo("error");
            _endpointConfiguration.AuditProcessedMessagesTo("audit");

            // setup transport
            _transportExtensions = _endpointConfiguration.UseTransport <RabbitMQTransport>();
            _transportExtensions.UseConventionalRoutingTopology();
            _transportExtensions.ConnectionString(transportConnectionString);
        }
        public static void ApplyConnectionString(this TransportExtensions <RabbitMQTransport> transport, string connectionString)
        {
            var builder = new DbConnectionStringBuilder {
                ConnectionString = connectionString
            };

            if (builder.GetBooleanValue("DisableRemoteCertificateValidation"))
            {
                transport.DisableRemoteCertificateValidation();
            }

            if (builder.GetBooleanValue("UseExternalAuthMechanism"))
            {
                transport.UseExternalAuthMechanism();
            }

            transport.ConnectionString(connectionString);
        }
Beispiel #16
0
 protected override void SetupTransport(TransportExtensions <RabbitMQTransport> extensions)
 {
     extensions.ConnectionString("host=localhost");
     extensions.UseDirectRoutingTopology();
 }
Beispiel #17
0
 public static void UseTestConnectionString(this TransportExtensions <RabbitMQTransport> extensions)
 {
     extensions.ConnectionString("host=localhost");
 }
Beispiel #18
0
 static void ConfigureTransport(TransportExtensions <RabbitMQTransport> transport, TransportSettings transportSettings)
 {
     transport.UseConventionalRoutingTopology();
     transport.Transactions(TransportTransactionMode.ReceiveOnly);
     transport.ConnectionString(transportSettings.ConnectionString);
 }
Beispiel #19
0
    public static void ConfigureASB(this TransportExtensions <AzureServiceBusTransport> extensions)
    {
        var connectionString = EnvironmentHelper.GetEnvironmentVariable("AzureServiceBus.ConnectionString");

        extensions.ConnectionString(connectionString);
    }
Beispiel #20
0
 public static void ConfigureSql(this TransportExtensions <SqlServerTransport> extensions)
 {
     extensions.ConnectionString(EnvironmentHelper.GetEnvironmentVariable("SqlServerTransportConnectionString"));
     extensions.Transactions(TransportTransactionMode.SendsAtomicWithReceive);
 }
Beispiel #21
0
    public static void ConfigureASQ(this TransportExtensions <AzureStorageQueueTransport> extensions)
    {
        var connectionString = EnvironmentHelper.GetEnvironmentVariable("AzureStorageQueues.ConnectionString");

        extensions.ConnectionString(connectionString);
    }
 static void ConfigureTransport(TransportExtensions <RabbitMQTransport> transport, TransportSettings transportSettings)
 {
     transport.UseDirectRoutingTopology(routingKeyConvention: type => type.FullName.Replace(".", "-"));
     transport.Transactions(TransportTransactionMode.ReceiveOnly);
     transport.ConnectionString(transportSettings.ConnectionString);
 }
        public static void ConfigureCommonSettings(this EndpointConfiguration endpointConfiguration, out TransportExtensions <RabbitMQTransport> transport)
        {
            endpointConfiguration.EnableInstallers();

            /*
             * This setting defines the transport that NServiceBus will use to send and receive messages.
             * We are using the Learning transport, which is bundled in the NServiceBus core library as a
             * starter transport for learning how to use NServiceBus without additional dependencies.
             */
            // transport = endpointConfiguration.UseTransport<LearningTransport>();

            transport = endpointConfiguration.UseTransport <RabbitMQTransport>();
            transport.UseConventionalRoutingTopology();
            transport.ConnectionString("host=localhost;username=guest;password=guest");

            // Configure immediately retry for transient exceptions
            var recoverability = endpointConfiguration.Recoverability();

            recoverability.Immediate(immediateRetriesSettings =>
            {
                // Number of times Immediate Retries are performed. Default: 5.
                immediateRetriesSettings.NumberOfRetries(3);
            });

            // Configuring delayed retries for semi-transient exceptions

            /* recoverability.Delayed(
             *  delayed =>
             *  {
             *      // delayed.NumberOfRetries(2);
             *      // delayed.TimeIncrease(TimeSpan.FromMinutes(5));
             *
             *      // To disable:
             *      // delayed.NumberOfRetries(0);
             *  }); */

            /* SAGA PERSISTENCE:
             * LearningPersistence which is designed for testing and development.
             * It stores data on the disk in a folder in the executable path.
             * In production use one of our production-level persistence options.
             *
             * For more info: https://docs.particular.net/persistence/#supported-persisters
             */
            /* var persistence = endpointConfiguration.UsePersistence<LearningPersistence>();
             * // persistence.SagaStorageDirectory("PathToStoreSagas"); */

            // Ensure an instance of PostgreSQL (Version 10 or later) is installed and accessible on localhost.
            var persistence = endpointConfiguration.UsePersistence <SqlPersistence>();

            var connection = "Host=localhost;Username=postgres;Password=Demo.01;Database=postgres";

            var dialect = persistence.SqlDialect <SqlDialect.PostgreSql>();

            dialect.JsonBParameterModifier(
                modifier: parameter =>
            {
                var npgsqlParameter          = (NpgsqlParameter)parameter;
                npgsqlParameter.NpgsqlDbType = NpgsqlDbType.Jsonb;
            });
            persistence.ConnectionBuilder(
                connectionBuilder: () => new NpgsqlConnection(connection));

            var subscriptions = persistence.SubscriptionSettings();

            subscriptions.CacheFor(TimeSpan.FromMinutes(1));

            /***************************************************************************************
            * Enabling auditing on all endpoints results in doubling the global message throughput.
            * That can sometimes be troublesome in high message volume environments.
            ***************************************************************************************/
            endpointConfiguration.AuditProcessedMessagesTo("targetAuditQueue");
        }
 protected override void Setup(TransportExtensions <AzureStorageQueueTransport> cfg)
 {
     cfg.ConnectionString(defaultConnectionString);
 }