コード例 #1
0
 public void Setup()
 {
     routingTable      = new UnicastRoutingTable();
     endpointInstances = new EndpointInstances();
     router            = new UnicastSendRouter(
         routingTable,
         endpointInstances,
         i => i.ToString());
 }
コード例 #2
0
 public void Setup()
 {
     routingTable = new UnicastRoutingTable();
     endpointInstances = new EndpointInstances();
     router = new UnicastSendRouter(
         routingTable,
         endpointInstances,
         i => i.ToString());
 }
コード例 #3
0
        protected internal override void Setup(FeatureConfigurationContext context)
        {
            var canReceive = !context.Settings.GetOrDefault<bool>("Endpoint.SendOnly");
            var transportInfrastructure = context.Settings.Get<TransportInfrastructure>();
            var conventions = context.Settings.Get<Conventions>();
            var unicastBusConfig = context.Settings.GetConfigSection<UnicastBusConfig>();

            var unicastRoutingTable = context.Settings.Get<UnicastRoutingTable>();
            var endpointInstances = context.Settings.Get<EndpointInstances>();
            var publishers = context.Settings.Get<Publishers>();
            var distributionPolicy = context.Settings.Get<DistributionPolicy>();
            var configuredUnicastRoutes = context.Settings.Get<ConfiguredUnicastRoutes>();
            var distributorAddress = context.Settings.GetOrDefault<string>("LegacyDistributor.Address");

            if (context.Settings.Get<bool>(EnforceBestPracticesSettingsKey))
            {
                EnableBestPracticeEnforcement(context);
            }

            unicastBusConfig?.MessageEndpointMappings.Apply(publishers, unicastRoutingTable, transportInfrastructure.MakeCanonicalForm, conventions);
            configuredUnicastRoutes.Apply(unicastRoutingTable, conventions);

            context.Pipeline.Register(b =>
            {
                var unicastSendRouter = new UnicastSendRouter(unicastRoutingTable, endpointInstances, i => transportInfrastructure.ToTransportAddress(LogicalAddress.CreateRemoteAddress(i)));
                return new UnicastSendRouterConnector(context.Settings.LocalAddress(), context.Settings.InstanceSpecificQueue(), distributorAddress, unicastSendRouter, distributionPolicy, i => transportInfrastructure.ToTransportAddress(LogicalAddress.CreateRemoteAddress(i)));
            }, "Determines how the message being sent should be routed");

            context.Pipeline.Register(new UnicastReplyRouterConnector(), "Determines how replies should be routed");

            if (canReceive)
            {
                var publicReturnAddress = context.Settings.GetOrDefault<string>("PublicReturnAddress");
                context.Pipeline.Register(new ApplyReplyToAddressBehavior(context.Settings.LocalAddress(), context.Settings.InstanceSpecificQueue(), publicReturnAddress, distributorAddress), "Applies the public reply to address to outgoing messages");
            }
        }
コード例 #4
0
ファイル: RoutingFeature.cs プロジェクト: vvsvvt/NServiceBus
        protected internal override void Setup(FeatureConfigurationContext context)
        {
            var canReceive = !context.Settings.GetOrDefault <bool>("Endpoint.SendOnly");
            var transportInfrastructure = context.Settings.Get <TransportInfrastructure>();
            var conventions             = context.Settings.Get <Conventions>();
            var unicastBusConfig        = context.Settings.GetConfigSection <UnicastBusConfig>();

            var unicastRoutingTable     = context.Settings.Get <UnicastRoutingTable>();
            var endpointInstances       = context.Settings.Get <EndpointInstances>();
            var publishers              = context.Settings.Get <Publishers>();
            var distributionPolicy      = context.Settings.Get <DistributionPolicy>();
            var configuredUnicastRoutes = context.Settings.Get <ConfiguredUnicastRoutes>();
            var distributorAddress      = context.Settings.GetOrDefault <string>("LegacyDistributor.Address");

            if (context.Settings.Get <bool>(EnforceBestPracticesSettingsKey))
            {
                EnableBestPracticeEnforcement(context);
            }

            unicastBusConfig?.MessageEndpointMappings.Apply(publishers, unicastRoutingTable, transportInfrastructure.MakeCanonicalForm, conventions);
            configuredUnicastRoutes.Apply(unicastRoutingTable, conventions);

            context.Pipeline.Register(b =>
            {
                var unicastSendRouter = new UnicastSendRouter(unicastRoutingTable, endpointInstances, i => transportInfrastructure.ToTransportAddress(LogicalAddress.CreateRemoteAddress(i)));
                return(new UnicastSendRouterConnector(context.Settings.LocalAddress(), context.Settings.InstanceSpecificQueue(), distributorAddress, unicastSendRouter, distributionPolicy, i => transportInfrastructure.ToTransportAddress(LogicalAddress.CreateRemoteAddress(i))));
            }, "Determines how the message being sent should be routed");

            context.Pipeline.Register(new UnicastReplyRouterConnector(), "Determines how replies should be routed");

            if (canReceive)
            {
                var publicReturnAddress = context.Settings.GetOrDefault <string>("PublicReturnAddress");
                context.Pipeline.Register(new ApplyReplyToAddressBehavior(context.Settings.LocalAddress(), context.Settings.InstanceSpecificQueue(), publicReturnAddress, distributorAddress), "Applies the public reply to address to outgoing messages");
            }
        }
コード例 #5
0
ファイル: RoutingFeature.cs プロジェクト: matucs/NServiceBus
        protected internal override void Setup(FeatureConfigurationContext context)
        {
            var canReceive = !context.Settings.GetOrDefault <bool>("Endpoint.SendOnly");
            var transportInfrastructure = context.Settings.Get <TransportInfrastructure>();

            var unicastRoutingTable = context.Settings.Get <UnicastRoutingTable>();
            var endpointInstances   = context.Settings.Get <EndpointInstances>();
            var publishers          = context.Settings.Get <Publishers>();

            var distributionPolicy      = context.Settings.Get <DistributionPolicy>();
            var configuredUnicastRoutes = context.Settings.Get <ConfiguredUnicastRoutes>();
            var configuredPublishers    = context.Settings.Get <ConfiguredPublishers>();
            var conventions             = context.Settings.Get <Conventions>();
            var unicastBusConfig        = context.Settings.GetConfigSection <UnicastBusConfig>();

            var enforceBestPractices = context.Settings.Get <bool>(EnforceBestPracticesSettingsKey);

            if (enforceBestPractices)
            {
                EnableBestPracticeEnforcement(context);
            }

            unicastBusConfig?.MessageEndpointMappings.Apply(publishers, unicastRoutingTable, transportInfrastructure.MakeCanonicalForm, conventions);
            configuredUnicastRoutes.Apply(unicastRoutingTable, conventions);
            configuredPublishers.Apply(publishers, conventions, enforceBestPractices);

            var outboundRoutingPolicy = transportInfrastructure.OutboundRoutingPolicy;

            context.Pipeline.Register(b =>
            {
                var unicastSendRouter = new UnicastSendRouter(unicastRoutingTable, endpointInstances, i => transportInfrastructure.ToTransportAddress(LogicalAddress.CreateRemoteAddress(i)));
                return(new UnicastSendRouterConnector(context.Settings.LocalAddress(), context.Settings.InstanceSpecificQueue(), unicastSendRouter, distributionPolicy, i => transportInfrastructure.ToTransportAddress(LogicalAddress.CreateRemoteAddress(i))));
            }, "Determines how the message being sent should be routed");

            context.Pipeline.Register(new UnicastReplyRouterConnector(), "Determines how replies should be routed");
            if (outboundRoutingPolicy.Publishes == OutboundRoutingType.Unicast)
            {
                context.Pipeline.Register(b =>
                {
                    var unicastPublishRouter = new UnicastPublishRouter(b.Build <MessageMetadataRegistry>(), b.Build <ISubscriptionStorage>());
                    return(new UnicastPublishRouterConnector(unicastPublishRouter, distributionPolicy));
                }, "Determines how the published messages should be routed");
            }
            else
            {
                context.Pipeline.Register(new MulticastPublishRouterBehavior(), "Determines how the published messages should be routed");
            }

            if (canReceive)
            {
                var publicReturnAddress = context.Settings.GetOrDefault <string>("PublicReturnAddress");
                var distributorAddress  = context.Settings.GetOrDefault <string>("LegacyDistributor.Address");
                context.Pipeline.Register(new ApplyReplyToAddressBehavior(context.Settings.LocalAddress(), context.Settings.InstanceSpecificQueue(), publicReturnAddress, distributorAddress), "Applies the public reply to address to outgoing messages");

                if (outboundRoutingPolicy.Publishes == OutboundRoutingType.Unicast)
                {
                    var subscriberAddress  = distributorAddress ?? context.Settings.LocalAddress();
                    var subscriptionRouter = new SubscriptionRouter(publishers, endpointInstances, i => transportInfrastructure.ToTransportAddress(LogicalAddress.CreateRemoteAddress(i)));

                    context.Pipeline.Register(b => new MessageDrivenSubscribeTerminator(subscriptionRouter, subscriberAddress, context.Settings.EndpointName(), b.Build <IDispatchMessages>()), "Sends subscription requests when message driven subscriptions is in use");
                    context.Pipeline.Register(b => new MessageDrivenUnsubscribeTerminator(subscriptionRouter, subscriberAddress, context.Settings.EndpointName(), b.Build <IDispatchMessages>()), "Sends requests to unsubscribe when message driven subscriptions is in use");
                }
                else
                {
                    var transportSubscriptionInfrastructure = transportInfrastructure.ConfigureSubscriptionInfrastructure();
                    var subscriptionManager = transportSubscriptionInfrastructure.SubscriptionManagerFactory();

                    context.Pipeline.Register(new NativeSubscribeTerminator(subscriptionManager), "Requests the transport to subscribe to a given message type");
                    context.Pipeline.Register(new NativeUnsubscribeTerminator(subscriptionManager), "Requests the transport to unsubscribe to a given message type");
                }
            }
        }