/// <summary>
        /// Enables routing configured with the routing configuration file.
        /// </summary>
        /// <param name="config">The configuration object.</param>
        /// <param name="updateInterval">The interval the route file should be checked for changes.</param>
        public static void UseFileBasedRouting(this RoutingSettings config, TimeSpan updateInterval)
        {
            if (updateInterval < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(updateInterval), "Update interval cannot be negative.");
            }

            config.GetSettings().Set(FileBasedRoutingFeature.RouteFileUpdateInterval, updateInterval);
            config.GetSettings().EnableFeatureByDefault <FileBasedRoutingFeature>();
        }
示例#2
0
 public PartitionAwareSenderSideDistributionConfiguration(RoutingSettings routingSettings, string endpointName, string[] partitions)
     : base(routingSettings.GetSettings())
 {
     this.routingSettings = routingSettings;
     this.endpointName    = endpointName;
     this.partitions      = partitions;
 }
 public static void RegisterPublisher(this RoutingSettings config, Type eventType, string publisherEndpoint)
 {
     config.GetSettings().GetOrCreate <Publishers>().AddOrReplacePublishers(Guid.NewGuid().ToString(),
                                                                            new List <PublisherTableEntry> {
         new PublisherTableEntry(eventType, PublisherAddress.CreateFromEndpointName(publisherEndpoint))
     });
 }
        /// <summary>
        /// Enables routing configured with the routing configuration file.
        /// </summary>
        /// <param name="config">The configuration object.</param>
        public static DatabaseBasedRoutingOptions UseDatabaseBasedRouting(this RoutingSettings config)
        {
            var settings = config.GetSettings();

            settings.EnableFeatureByDefault <DatabaseBasedRoutingFeature>();
            return(new DatabaseBasedRoutingOptions(settings));
        }
        /// <summary>
        /// Enables routing configured with the routing configuration file under <paramref name="configurationFilePath"/>
        /// </summary>
        /// <param name="config">The configuration object.</param>
        /// <param name="connectionString">The connection string to the routing configuration database.</param>
        public static DatabaseBasedRoutingOptions UseDatabaseBasedRouting(this RoutingSettings config, string connectionString)
        {
            var settings = config.GetSettings();

            settings.Set(DatabaseBasedRoutingFeature.DatabaseConnectionKey, connectionString);
            settings.EnableFeatureByDefault <DatabaseBasedRoutingFeature>();
            return(new DatabaseBasedRoutingOptions(settings));
        }
    public static void ForwardToEndpoint(this RoutingSettings routing, Type messageTypeToForward, string destinationEndpointName)
    {
        var settings = routing.GetSettings();

        var endpointRoute = UnicastRoute.CreateFromEndpointName(destinationEndpointName);

        settings.GetOrCreate <ForwardingAddressDirectory>()
        .ForwardToRoute(messageTypeToForward, endpointRoute);

        settings.EnableFeatureByDefault <LeaveForwardingAddressFeature>();
    }
示例#7
0
    public static PartitionAwareReceiverSideDistributionConfiguration EnableReceiverSideDistribution(this RoutingSettings routingSettings, string[] discriminators)
    {
        var settings = routingSettings.GetSettings();

        if (!settings.TryGet(out PartitionAwareReceiverSideDistributionConfiguration 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 RegisterEndpointInstances(this RoutingSettings config, params EndpointInstance[] instances)
 {
     config.GetSettings().GetOrCreate <EndpointInstances>().AddOrReplaceInstances(Guid.NewGuid().ToString(), instances);
 }
 /// <summary>
 /// Enables routing configured with the routing configuration file under <paramref name="configurationFileUri"/>
 /// </summary>
 /// <param name="config">The configuration object.</param>
 /// <param name="configurationFileUri">The <see cref="Uri"/> to the configuration file.</param>
 public static void UseFileBasedRouting(this RoutingSettings config, Uri configurationFileUri)
 {
     config.GetSettings().Set(FileBasedRoutingFeature.RoutingFilePathKey, configurationFileUri);
     config.GetSettings().EnableFeatureByDefault <FileBasedRoutingFeature>();
 }
 /// <summary>
 /// Enables routing configured with the routing configuration file.
 /// </summary>
 /// <param name="config">The configuration object.</param>
 public static void UseFileBasedRouting(this RoutingSettings config)
 {
     config.GetSettings().EnableFeatureByDefault <FileBasedRoutingFeature>();
 }
示例#12
0
 public PartitionAwareReceiverSideDistributionConfiguration(RoutingSettings routingSettings, string[] partitions)
     : base(routingSettings.GetSettings())
 {
     Partitions = new HashSet <string>(partitions);
 }