Ejemplo n.º 1
0
    public TransportConfigurationResult Configure(SettingsHolder settings, TransportTransactionMode transportTransactionMode)
    {
#if !NETFRAMEWORK
        if (transportTransactionMode == TransportTransactionMode.TransactionScope)
        {
            NUnit.Framework.Assert.Ignore("TransactionScope not supported in .NET Core");
        }
#endif
        this.settings = settings;
        settings.Set(transportTransactionMode);
        settings.Set("NServiceBus.SharedQueue", settings.EndpointName());
        var delayedDeliverySettings = new DelayedDeliverySettings(settings);
        delayedDeliverySettings.TableSuffix("Delayed");

        var pubSubSettings = new SubscriptionSettings();
        pubSubSettings.DisableSubscriptionCache();
        settings.Set(pubSubSettings);

        connectionString = Environment.GetEnvironmentVariable("SqlServerTransportConnectionString");
        if (string.IsNullOrEmpty(connectionString))
        {
            connectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=nservicebus;Integrated Security=True";
        }

        var logicalAddress = LogicalAddress.CreateLocalAddress(settings.ErrorQueueAddress(), new Dictionary <string, string>());
        var localAddress   = settings.EndpointName();
        return(new TransportConfigurationResult
        {
            TransportInfrastructure = new SqlServerTransportInfrastructure("nservicebus", settings, connectionString, () => localAddress, () => logicalAddress, false)
        });
    }
Ejemplo n.º 2
0
        protected override async Task ExecuteAsync(CancellationToken token)
        {
            const string EndpointName          = "endpoint name";
            var          endpointConfiguration = new EndpointConfiguration(EndpointName);

            endpointConfiguration.UniquelyIdentifyRunningInstance().UsingNames(EndpointName, Environment.MachineName);


            endpointConfiguration.SendFailedMessagesTo("error");
            endpointConfiguration.AuditProcessedMessagesTo("audit");

            endpointConfiguration.DefineCriticalErrorAction(OnCriticalError);

            ConventionsBuilder conventions = endpointConfiguration.Conventions();

            conventions
            .DefiningEventsAs(_ => _.Name.EndsWith("Event"))
            .DefiningCommandsAs(_ => _.Name.EndsWith("Command"))
            .DefiningMessagesAs(_ => _.Name.EndsWith("Message"));

            TransportExtensions <SqlServerTransport> transport =
                endpointConfiguration.UseTransport <SqlServerTransport>();

            NServiceBus.Transport.SQLServer.SubscriptionSettings
                subscriptionSettings = transport.SubscriptionSettings();
            subscriptionSettings.DisableSubscriptionCache();
            subscriptionSettings.SubscriptionTableName("subscriptions", "transportSchema");

            transport.Routing().RouteToEndpoint(
                Assembly.GetAssembly(typeof(MyCommand)),
                EndpointName);


            DelayedDeliverySettings delayedDeliverySettings = transport.NativeDelayedDelivery();

            delayedDeliverySettings.DisableTimeoutManagerCompatibility();

            transport
            .Transactions(TransportTransactionMode.ReceiveOnly)
            .ConnectionString("Data Source=sqlserver;Initial Catalog=transport;User ID=worker;Password=password;Max Pool Size=100;")
            .TransactionScopeOptions(TimeSpan.FromSeconds(30), IsolationLevel.ReadCommitted)
            .DefaultSchema("transportSchema");

            this.endpoint = await Endpoint.Start(endpointConfiguration);

            while (!token.IsCancellationRequested)
            {
                await Task.Delay(1000, token);
            }
        }
Ejemplo n.º 3
0
    public TransportConfigurationResult Configure(SettingsHolder settings, TransportTransactionMode transportTransactionMode)
    {
        this.settings = settings;
        settings.Set("NServiceBus.SharedQueue", settings.EndpointName());
        settings.Set <LogicalAddress>(LogicalAddress.CreateLocalAddress(settings.EndpointName(), new Dictionary <string, string>()));
        var delayedDeliverySettings = new DelayedDeliverySettings();

        delayedDeliverySettings.TableSuffix("Delayed");
        settings.Set <DelayedDeliverySettings>(delayedDeliverySettings);
        return(new TransportConfigurationResult
        {
            TransportInfrastructure = new SqlServerTransport().Initialize(settings, ConnectionString)
        });
    }