Exemplo n.º 1
0
        /// <summary>
        /// Instructs the endpoint configuration to connect to a designated router. A single endpoint can connect to a single router.
        /// </summary>
        /// <param name="routingSettings">Routing settings.</param>
        /// <param name="routerAddress">Transport address of router's interface.</param>
        public static RouterConnectionSettings ConnectToRouter(this RoutingSettings routingSettings, string routerAddress)
        {
            routingSettings.GetSettings().EnableFeatureByDefault(typeof(RouterConnectionFeature));

            var settings = new RouterConnectionSettings(routerAddress);

            routingSettings.GetSettings().Set <RouterConnectionSettings>(settings);
            return(settings);
        }
        /// <summary>
        /// Instructs the endpoint configuration to connect to a designated bridge. A single endpoint can connect to a single bridge.
        /// </summary>
        /// <param name="routingSettings">Routing settings.</param>
        /// <param name="bridgeAddress">Transport address of the bridge.</param>
        public static BridgeRoutingSettings ConnectToBridge(this RoutingSettings routingSettings, string bridgeAddress)
        {
            routingSettings.GetSettings().EnableFeatureByDefault(typeof(BridgeRoutingFeature));

            var settings = new BridgeRoutingSettings(bridgeAddress);

            routingSettings.GetSettings().Set <BridgeRoutingSettings>(settings);
            return(settings);
        }
        public static RampSettings UseBridgeRamp(this RoutingSettings routingSettings, string bridgeAddress)
        {
            routingSettings.GetSettings().EnableFeatureByDefault(typeof(RampFeature));

            var rampSettings = new RampSettings(bridgeAddress);

            routingSettings.GetSettings().Set <RampSettings>(rampSettings);
            return(rampSettings);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Sets a distribution strategy for a given endpoint.
        /// </summary>
        /// <param name="config">MSMQ Transport configuration object.</param>
        /// <param name="distributionStrategy">The instance of a distribution strategy.</param>
        public static void SetMessageDistributionStrategy(this RoutingSettings <MsmqTransport> config, DistributionStrategy distributionStrategy)
        {
            Guard.AgainstNull(nameof(config), config);
            Guard.AgainstNull(nameof(distributionStrategy), distributionStrategy);

            config.GetSettings().GetOrCreate <List <DistributionStrategy> >().Add(distributionStrategy);
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Enables compatibility with endpoints running on message-driven pub-sub
        /// </summary>
        /// <param name="routingSettings">The transport to enable pub-sub compatibility on</param>
        public static SubscriptionMigrationModeSettings EnableMessageDrivenPubSubCompatibilityMode(
            this RoutingSettings routingSettings)
        {
            var settings = routingSettings.GetSettings();

            settings.Set("NServiceBus.Subscriptions.EnableMigrationMode", true);
            return(new SubscriptionMigrationModeSettings(settings));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Specifies custom catalog for given endpoint.
        /// </summary>
        /// <param name="settings">The <see cref="RoutingSettings" /> to extend.</param>
        /// <param name="endpointName">Endpoint name.</param>
        /// <param name="catalog">Custom catalog value.</param>
        public static void UseCatalogForEndpoint(this RoutingSettings settings, string endpointName, string catalog)
        {
            Guard.AgainstNull(nameof(endpointName), endpointName);

            var localEndpointName = settings.GetSettings().EndpointName();

            if (endpointName.Equals(localEndpointName))
            {
                throw new ArgumentException("Custom catalog cannot be specified for the local endpoint. Local endpoint's schema can be specified with DefaultSchema transport setting.");
            }

            var schemaAndCatalogSettings = settings.GetSettings().GetOrCreate <EndpointSchemaAndCatalogSettings>();

            schemaAndCatalogSettings.SpecifyCatalog(endpointName, catalog);

            settings.GetSettings().GetOrCreate <EndpointInstances>()
            .AddOrReplaceInstances("SqlServer", schemaAndCatalogSettings.ToEndpointInstances());
        }
        static RouterConnectionSettings ConnectToRouterImpl(RoutingSettings routingSettings, string routerAddress, bool enableAutoSubscribe, bool enableAutoPublish)
        {
            var settingsHolder = routingSettings.GetSettings();

            settingsHolder.EnableFeatureByDefault(typeof(RouterConnectionFeature));

            if (!settingsHolder.TryGet(out RouterConnectionSettingsCollection connectionSettings))
            {
                connectionSettings = new RouterConnectionSettingsCollection();
                settingsHolder.Set(connectionSettings);
            }

            return(connectionSettings.GetOrCreate(routerAddress, enableAutoSubscribe, enableAutoPublish));
        }
        public static PartitionAwareReceiverSideDistributionConfiguration EnableReceiverSideDistribution(
            this RoutingSettings routingSettings, string[] discriminators)
        {
            var settings = routingSettings.GetSettings();

            if (settings.TryGet(out PartitionAwareReceiverSideDistributionConfiguration config))
            {
                return(config);
            }

            config = new PartitionAwareReceiverSideDistributionConfiguration(routingSettings, discriminators);
            settings.Set <PartitionAwareReceiverSideDistributionConfiguration>(config);
            settings.Set(typeof(ReceiverSideDistribution).FullName, FeatureState.Enabled);

            return(config);
        }
        public static PartitionAwareSenderSideDistributionConfiguration RegisterPartitionedDestinationEndpoint <T>(
            this RoutingSettings <T> routingSettings, string destinationEndpoint, string[] partitions)
            where T : TransportDefinition
        {
            var settings = routingSettings.GetSettings();

            var distributionConfiguration =
                new PartitionAwareSenderSideDistributionConfiguration(routingSettings, destinationEndpoint, partitions);

            var sendDistributionStrategy = new PartitionAwareDistributionStrategy(destinationEndpoint,
                                                                                  distributionConfiguration.MapMessageToPartitionKey, DistributionStrategyScope.Send);
            var distributionPolicy = settings.GetOrCreate <DistributionPolicy>();

            distributionPolicy.SetDistributionStrategy(sendDistributionStrategy);

            var destinationEndpointInstances =
                partitions.Select(key => new EndpointInstance(destinationEndpoint, key)).ToList();

            var endpointInstances = settings.GetOrCreate <EndpointInstances>();

            endpointInstances.AddOrReplaceInstances(destinationEndpoint, destinationEndpointInstances);

            return(distributionConfiguration);
        }
 public static void EnableAutomaticRouting(this RoutingSettings settings)
 {
     settings.GetSettings().EnableFeatureByDefault(typeof(BackplaneBasedRouting));
     settings.GetSettings().Set(typeof(AutoSubscribe).FullName, FeatureState.Disabled);
 }
 /// <summary>
 /// Returns the configuration options for the file based instance mapping file.
 /// </summary>
 public static InstanceMappingFileSettings InstanceMappingFile(this RoutingSettings<MsmqTransport> config)
 {
     Guard.AgainstNull(nameof(config), config);
     return new InstanceMappingFileSettings(config.GetSettings());
 }